@sandboxrouter/sdk 0.10.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.
Files changed (51) hide show
  1. package/README.md +3 -2
  2. package/dist/agent-bench.d.ts +39 -0
  3. package/dist/agent-bench.js +150 -0
  4. package/dist/bench-store.js +11 -2
  5. package/dist/bench.d.ts +12 -0
  6. package/dist/bench.js +24 -3
  7. package/dist/burst.d.ts +81 -0
  8. package/dist/burst.js +183 -0
  9. package/dist/catalog.d.ts +12 -0
  10. package/dist/catalog.js +15 -11
  11. package/dist/check.d.ts +2 -0
  12. package/dist/check.js +8 -0
  13. package/dist/cli.js +200 -5
  14. package/dist/index.d.ts +2 -0
  15. package/dist/index.js +2 -0
  16. package/dist/leaderboard.d.ts +74 -2
  17. package/dist/leaderboard.js +117 -7
  18. package/dist/ledger.d.ts +2 -0
  19. package/dist/ledger.js +12 -1
  20. package/dist/price-index.d.ts +54 -0
  21. package/dist/price-index.js +50 -0
  22. package/dist/providers/beam.js +4 -0
  23. package/dist/providers/blaxel.js +4 -0
  24. package/dist/providers/boat.js +3 -1
  25. package/dist/providers/daytona.js +4 -0
  26. package/dist/providers/deno.js +4 -0
  27. package/dist/providers/e2b.d.ts +2 -0
  28. package/dist/providers/e2b.js +4 -0
  29. package/dist/providers/hopx.js +4 -0
  30. package/dist/providers/langsmith.js +4 -0
  31. package/dist/providers/modal.js +11 -2
  32. package/dist/providers/morph.js +4 -0
  33. package/dist/providers/runloop.js +4 -0
  34. package/dist/providers/sprites.js +4 -0
  35. package/dist/providers/tensorlake.js +4 -0
  36. package/dist/providers/vercel.js +4 -0
  37. package/dist/published.d.ts +2 -0
  38. package/dist/published.js +2087 -0
  39. package/dist/recommend.d.ts +117 -0
  40. package/dist/recommend.js +103 -0
  41. package/dist/results.js +63 -1
  42. package/dist/router.d.ts +45 -0
  43. package/dist/router.js +69 -4
  44. package/dist/submit.d.ts +6 -0
  45. package/dist/submit.js +70 -0
  46. package/dist/task.d.ts +17 -2
  47. package/dist/task.js +74 -19
  48. package/dist/types.d.ts +5 -0
  49. package/dist/util.d.ts +2 -0
  50. package/dist/util.js +2 -0
  51. package/package.json +1 -1
package/dist/catalog.js CHANGED
@@ -91,7 +91,7 @@ const ENTRIES = [
91
91
  gbHour: 0.0162,
92
92
  note: "per second, plus disk above 5 GiB",
93
93
  source: "https://www.daytona.io/pricing",
94
- checked: "2026-11-13",
94
+ checked: "2026-11-17",
95
95
  },
96
96
  capabilities: ["pause", "custom-image"],
97
97
  limits: { maxVcpu: 4, maxMemoryGb: 8 },
@@ -105,10 +105,12 @@ const ENTRIES = [
105
105
  name: "Modal",
106
106
  pricing: {
107
107
  vcpuHour: 0.070956,
108
+ reservesCpu: true,
109
+ cpuFloor: 0.125,
108
110
  gbHour: 0.024012,
109
111
  note: "sandbox rates, per second ($0.00003942 per physical core = 2 vCPUs); GPUs extra; region pinning x1.15-1.75; Starter includes $30/mo credit",
110
112
  source: "https://modal.com/pricing",
111
- checked: "2026-11-05",
113
+ checked: "2026-11-17",
112
114
  },
113
115
  capabilities: ["gpu", "custom-image"],
114
116
  limits: { maxVcpu: 64, maxMemoryGb: 256 },
@@ -121,6 +123,7 @@ const ENTRIES = [
121
123
  pricing: {
122
124
  minSeconds: 60,
123
125
  minimumCovers: "memory",
126
+ cpuMeteredPerVm: true,
124
127
  vcpuHour: 0.128,
125
128
  gbHour: 0.0212,
126
129
  note: "iad1; active CPU (I/O wait free), provisioned RAM in minimum 1-minute increments (2 GB/vCPU); listed at full CPU, cpuUtilization lowers it; Hobby free within quotas, Pro $20/mo usage credit; creations $0.60/million and retained snapshots $0.08/GB-month extra",
@@ -317,7 +320,7 @@ ENTRIES.push({
317
320
  gbHour: 0,
318
321
  note: "flat $0.03 per session-hour (built-in Shell pools), billed per allocated session in 1-hour increments, East US; needs a session pool you create once",
319
322
  source: "https://learn.microsoft.com/en-us/azure/container-apps/billing#dynamic-sessions",
320
- checked: "2026-11-04",
323
+ checked: "2026-11-17",
321
324
  },
322
325
  capabilities: [],
323
326
  // Per-session size isn't published; placeholder until measured with nproc / free.
@@ -368,7 +371,7 @@ ENTRIES.push({
368
371
  gbHour: 0.008928,
369
372
  note: "per second; Default QoS, Hong Kong and regions outside mainland China; disk separately $0.00025308/GiB-h; code-interpreter-v1 template is 2 vCPU / 2 GiB with 10 GiB disk (E2B-compatible API)",
370
373
  source: "https://www.alibabacloud.com/help/en/agent-sandbox/product-overview/billing-overview",
371
- checked: "2026-11-05",
374
+ checked: "2026-11-17",
372
375
  },
373
376
  capabilities: ["custom-image"],
374
377
  // No published maximum; the default template is 2 vCPU / 2 GB, so bigger requests go elsewhere.
@@ -443,7 +446,7 @@ ENTRIES.push({
443
446
  gbHour: 0.001,
444
447
  note: "per second on allocated size; no platform fee or minimum; paused = free; size comes from the template (E2B-compatible API); Singapore only; needs a pay-as-you-go key",
445
448
  source: "https://openscale.so/sandboxes",
446
- checked: "2026-11-05",
449
+ checked: "2026-11-17",
447
450
  },
448
451
  capabilities: ["pause", "custom-image"],
449
452
  limits: { maxVcpu: 8, maxMemoryGb: 16 },
@@ -474,7 +477,7 @@ ENTRIES.push({
474
477
  gbHour: 0.025,
475
478
  note: "billed on CPU time, not wall clock (estimate assumes both vCPUs busy); fixed 2 vCPU, 0.75-4 GB, max 30 min lifetime; needs a paid Deno Deploy plan",
476
479
  source: "https://deno.com/sandbox",
477
- checked: "2026-11-04",
480
+ checked: "2026-11-17",
478
481
  },
479
482
  capabilities: ["custom-image"],
480
483
  limits: { maxVcpu: 2, maxMemoryGb: 4 },
@@ -502,7 +505,7 @@ ENTRIES.push({
502
505
  gbHour: 0.00225,
503
506
  note: "per second while running on fixed sizes (2/4, 4/8, 8/16); paused or stopped boxes bill only /data beyond the included disk ($0.00011/GiB-h); Pro $20/mo includes $20 credits; free plan: 1 box at 4/8",
504
507
  source: "https://instabox.sh/docs/pricing.md",
505
- checked: "2026-11-05",
508
+ checked: "2026-11-17",
506
509
  },
507
510
  capabilities: ["pause", "custom-image"],
508
511
  limits: { maxVcpu: 8, maxMemoryGb: 16 },
@@ -536,7 +539,7 @@ ENTRIES.push({
536
539
  gbHour: 0.01845,
537
540
  note: "per second; memory must be 2 to 6 GiB per vCPU; storage $0.000123/GiB-h; 8 LSU ($8) of sandbox usage a month included; Developer plan max 10 sandboxes",
538
541
  source: "https://www.langchain.com/pricing",
539
- checked: "2026-11-05",
542
+ checked: "2026-11-17",
540
543
  },
541
544
  capabilities: ["pause", "custom-image"],
542
545
  // Not published; 16 vCPU / 96 GiB stays inside the 6 GiB per vCPU band. Real runs will tell.
@@ -568,9 +571,9 @@ ENTRIES.push({
568
571
  pricing: {
569
572
  vcpuHour: 0.1,
570
573
  gbHour: 0,
571
- note: "billed per active CPU core-hour only (memory and idle time free); estimate assumes every core of the box busy; fixed sizes 2/4, 4/8, 8/16",
574
+ note: "billed per active CPU core-hour only (memory and idle time free); estimate assumes every core of the box busy at the Small rate; fixed sizes 2/4, 4/8, 8/16, and the pricing page lists $0.20 (4/8) and $0.40 (8/16) per active CPU hour without saying whether that is per core or per box",
572
575
  source: "https://upstash.com/pricing/box",
573
- checked: "2026-11-04",
576
+ checked: "2026-11-17",
574
577
  },
575
578
  capabilities: [],
576
579
  limits: { maxVcpu: 8, maxMemoryGb: 16 },
@@ -789,7 +792,8 @@ export function hourlyCost(id, spec = {}) {
789
792
  /** The CPU part of the full-use hourly price for an "active-cpu" provider; 0 for providers that bill allocated capacity. */
790
793
  export function cpuHourlyAtFull(id, spec = {}) {
791
794
  const p = info(id);
792
- if (p.billing !== "active-cpu")
795
+ const reserved = p.pricing.reservesCpu && (spec.cpuUtilization ?? 1) < 1;
796
+ if (p.billing !== "active-cpu" && !reserved)
793
797
  return 0;
794
798
  const fixed = fixedSize(id, spec);
795
799
  if (fixed)
package/dist/check.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import type { Router } from "./router.js";
2
2
  import type { ProviderId, SandboxSpec } from "./types.js";
3
3
  /** Every step `check` runs, in order. Each provider's saved report is scored against this list. */
4
+ /** An account that can't start sandboxes at all: no credit, a frozen workspace, or a key or plan without access. */
5
+ export declare const ACCOUNT_BLOCKED: RegExp;
4
6
  export declare const CHECK_STEPS: readonly ["create", "exec: stdout, stderr, exit code", "exec: env and cwd", "exec: UTF-8 output", "exec: streaming", "files: binary round-trip", "files: 1 MB round-trip", "files: missing file is an error", "files: visible to commands", "exec: command timeout", "exec: timed-out command was stopped", "pause and resume", "kill", "killed sandbox is gone"];
5
7
  export type CheckStatus = "pass" | "fail" | "skip" | "info";
6
8
  export interface CheckResult {
package/dist/check.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import { fixedSize } from "./catalog.js";
2
2
  /** Every step `check` runs, in order. Each provider's saved report is scored against this list. */
3
+ /** An account that can't start sandboxes at all: no credit, a frozen workspace, or a key or plan without access. */
4
+ export const ACCOUNT_BLOCKED = /insufficient_credits|insufficient credit|workspace has been frozen|spending limit|HTTP 403|\b403\b.*Forbidden|Payment Required/i;
3
5
  export const CHECK_STEPS = [
4
6
  "create",
5
7
  "exec: stdout, stderr, exit code",
@@ -53,6 +55,12 @@ export async function checkProvider(router, provider, opts = {}) {
53
55
  notRun = "the account running the check can't pay (402)";
54
56
  return { status: "skip", detail: `the account can't pay (402), so this run says nothing about ${provider}: ${msg}` };
55
57
  }
58
+ // The account itself can't start sandboxes (no credit, a frozen workspace, a plan without sandboxes): that's the
59
+ // account running the check, not the provider.
60
+ if (ACCOUNT_BLOCKED.test(msg)) {
61
+ notRun = "the account running the check can't start sandboxes (credit, plan or a frozen workspace)";
62
+ return { status: "skip", detail: `${notRun}, so this run says nothing about ${provider}: ${msg}` };
63
+ }
56
64
  // The provider's SDK isn't installed where the check runs: that says nothing about the provider.
57
65
  const pkg = /needs the "([^"]+)" package/.exec(msg)?.[1];
58
66
  if (!pkg)
package/dist/cli.js CHANGED
@@ -2,8 +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
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. */
7
11
  import { costMarkdown, costRun, settle } from "./cost.js";
8
12
  import { checkProvider } from "./check.js";
9
13
  import { gc, listOpen } from "./gc.js";
@@ -12,6 +16,8 @@ import { loadReports, makeReport, renderLeaderboard } from "./leaderboard.js";
12
16
  import { DEFAULT_MEMORY_GB, DEFAULT_VCPU, accessLabel, benchmarksPublishable, hourlyCost, listingOrder, planLabel, unfit } from "./catalog.js";
13
17
  import { Router, rankUsd, runHours } from "./router.js";
14
18
  import { createApp } from "./server.js";
19
+ import { PUBLISHED } from "./published.js";
20
+ import { recommend } from "./recommend.js";
15
21
  import { RouterError } from "./types.js";
16
22
  const HELP = `sandboxrouter: one API for every sandbox provider
17
23
 
@@ -19,6 +25,10 @@ Usage:
19
25
  sandboxrouter providers [--vcpu N] [--memory GB] price table + which keys are set
20
26
  sandboxrouter route [spec flags] [route flags] dry run: the order providers would be tried
21
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
22
32
  sandboxrouter run "<cmd>" [spec flags] [route flags] [--keep]
23
33
  sandboxrouter check --provider ID[,ID] | --all [--json] [--save [dir]] [--retry] [--out FILE] [--by GITHUB_USER]
24
34
  test providers for real: exec, env, UTF-8, streaming, files, timeout, pause,
@@ -29,11 +39,20 @@ Usage:
29
39
  sandboxrouter ls [--json] sandboxes this machine started that weren't killed
30
40
  sandboxrouter gc [--all | --older-than MIN] [--dry-run]
31
41
  kill leaked sandboxes: by default those past their lifetime
32
- sandboxrouter bench [--runs 3] [--provider a,b] [--task [--long]] [--parallel N] [--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]]
33
43
  --task also runs the same fixed job in each sandbox (hash 512 MB on 1 core,
34
44
  then on 2, write 256 MB to disk) and prices it with each provider's billing rules;
35
45
  --long runs that job 40 times in a row (minutes); --job python (a pure-Python script)
36
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
37
56
  sandboxrouter cost run [--provider a,b] [--minutes 10] [--vcpu 2 --memory 4] [--no-load] [--out FILE] [--by GITHUB_USER]
38
57
  start one sandbox per provider for a fixed time with every core busy, record
39
58
  the size it really got and the list-price prediction
@@ -76,7 +95,14 @@ const { values, positionals } = parseArgs({
76
95
  task: { type: "boolean" },
77
96
  long: { type: "boolean" },
78
97
  job: { type: "string" },
98
+ count: { type: "string" },
99
+ priority: { type: "string" },
100
+ reuse: { type: "boolean" },
101
+ spread: { type: "boolean" },
102
+ even: { type: "boolean" },
79
103
  parallel: { type: "string" },
104
+ n: { type: "string" },
105
+ model: { type: "string" },
80
106
  json: { type: "boolean" },
81
107
  port: { type: "string" },
82
108
  host: { type: "string" },
@@ -86,6 +112,7 @@ const { values, positionals } = parseArgs({
86
112
  control: { type: "boolean" },
87
113
  out: { type: "string" },
88
114
  share: { type: "boolean" },
115
+ submit: { type: "boolean" },
89
116
  cors: { type: "string" },
90
117
  label: { type: "string" },
91
118
  all: { type: "boolean" },
@@ -170,6 +197,31 @@ async function main() {
170
197
  ].join("\n"));
171
198
  return;
172
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
+ }
173
225
  if (cmd === "quote") {
174
226
  const q = router.quote(spec, route);
175
227
  if (values.json)
@@ -324,6 +376,125 @@ async function main() {
324
376
  process.exitCode = 1;
325
377
  return;
326
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
+ }
327
498
  if (cmd === "bench") {
328
499
  const job = (values.long ? "long" : values.job ?? "short");
329
500
  if (!(job in TASKS))
@@ -345,15 +516,39 @@ async function main() {
345
516
  console.log(benchMarkdown(rows));
346
517
  for (const r of rows.filter((r) => r.lastError))
347
518
  console.error(`\n${r.provider} last error: ${r.lastError}`);
348
- if (values.share) {
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) {
349
527
  const version = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
350
- const report = makeReport(rows, { 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 });
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 });
351
534
  const left = rows.filter((r) => !benchmarksPublishable(r.provider)).map((r) => r.provider);
352
535
  if (left.length)
353
536
  console.log(`\nleft out of the shared report: ${left.join(", ")} (their terms don't allow publishing benchmarks)`);
354
537
  const file = values.out ?? `sandboxrouter-bench-${report.date.slice(0, 10)}-${Math.random().toString(36).slice(2, 8)}.json`;
355
538
  writeFileSync(file, JSON.stringify(report, null, 2) + "\n");
356
- console.log(`\nwrote ${file}. Add it to results/ in a PR to github.com/gigialc/sandboxrouter to put it on the leaderboard.`);
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
+ }
357
552
  }
358
553
  return;
359
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";
@@ -38,6 +38,8 @@ export interface LeaderRow {
38
38
  medianCreateMs?: number;
39
39
  medianExecMs?: number;
40
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;
41
43
  /** List price for the size the bench runs it at (`size`). */
42
44
  hourlyUsd: number;
43
45
  /** The size bench runs: 2 vCPU / 4 GB, or the provider's fixed default size. */
@@ -49,8 +51,10 @@ export interface LeaderRow {
49
51
  measuredAt: string;
50
52
  }
51
53
  /**
52
- * Each provider's latest run from each location (report label), then the median across locations, so
53
- * an old run can't outvote a newer one and one heavy submitter can't skew a provider.
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.
54
58
  */
55
59
  export declare function aggregate(reports: BenchReport[]): LeaderRow[];
56
60
  export interface TaskRow {
@@ -68,6 +72,12 @@ export interface TaskRow {
68
72
  hourlyUsd: number;
69
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. */
70
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;
71
81
  /** CPU time the task used across all vCPUs (median), where the sandbox shows /proc/stat. */
72
82
  cpuMs?: number;
73
83
  /** True when the provider bills CPU only while busy, so `taskUsd` counts `cpuMs` rather than every core. */
@@ -84,3 +94,65 @@ export interface TaskRow {
84
94
  export declare function taskTable(reports: BenchReport[], version?: string): TaskRow[];
85
95
  /** One self-contained HTML page: a sorted table with an inline bar per measure, each on its own scale. */
86
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
+ }[];