@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/dist/cli.js CHANGED
@@ -2,7 +2,7 @@
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 { ACCOUNT_ERROR, bench, benchMarkdown, NETWORK_ERROR } from "./bench.js";
5
+ import { bench, benchMarkdown, NETWORK_ERROR } from "./bench.js";
6
6
  import { TASKS } from "./task.js";
7
7
  import { submitReport } from "./submit.js";
8
8
  import { burst, spreadBurst } from "./burst.js";
@@ -254,13 +254,18 @@ async function main() {
254
254
  if (values.json)
255
255
  return console.log(JSON.stringify({ ...q, candidates: undefined }, null, 2));
256
256
  const rules = [
257
- q.minimumSeconds ? `at least ${q.minimumSeconds} s billed` : "",
257
+ q.minimumSeconds ? `at least ${q.minimumSeconds} s billed${q.minimumCovers === "memory" ? " for memory" : ""}` : "",
258
258
  q.billedInSecondsOf ? `billed in steps of ${q.billedInSecondsOf} s` : "",
259
259
  q.perSandboxUsd ? `$${q.perSandboxUsd} per sandbox` : "",
260
260
  ].filter(Boolean);
261
261
  console.log(`${q.provider}, ${q.size.vcpu} vCPU / ${q.size.memoryGb} GB`);
262
262
  console.log(`price $${q.hourlyUsd.toFixed(4)}/hr${rules.length ? ` (${rules.join(", ")})` : ""}`);
263
263
  console.log(`this run ${q.runSeconds} s ≈ $${q.estimatedUsd.toFixed(6)} ($${q.runHourlyUsd.toFixed(4)}/hr)`);
264
+ const extra = q.conditionalStartFee;
265
+ if (extra)
266
+ console.log(`Excludes $${extra.minUsd}–$${extra.maxUsd} per start above your allowance. ${extra.source}`);
267
+ if (q.excludesGpuCost)
268
+ console.log("The estimate excludes GPU charges. Check your provider's GPU rates.");
264
269
  const next = q.candidates.filter((c) => !c.skip && c.provider !== q.provider).slice(0, 3).map((c) => c.provider);
265
270
  if (next.length)
266
271
  console.log(`fallback ${next.join(" → ")}`);
@@ -282,7 +287,10 @@ async function main() {
282
287
  // With --expect, what that run would be billed (minimum charge and fee included): what it's ranked by.
283
288
  const hours = runHours(spec);
284
289
  const run = spec.expectedSeconds ? ` ≈ $${(rankUsd(c, hours) * hours).toFixed(6)} for ${Math.round(hours * 3600)} s` : "";
285
- const cols = [`$${c.estimatedHourlyUsd.toFixed(4)}/hr${list}${fee}${run}`, size, speed, tested].filter(Boolean).join(" ");
290
+ const extra = c.conditionalStartFee;
291
+ const feeNote = extra ? `excludes $${extra.minUsd}–$${extra.maxUsd} per start above allowance` : "";
292
+ const gpuNote = c.excludesGpuCost ? "excludes GPU charges" : "";
293
+ const cols = [`$${c.estimatedHourlyUsd.toFixed(4)}/hr${list}${fee}${run}`, size, speed, tested, feeNote, gpuNote].filter(Boolean).join(" ");
286
294
  console.log(`${mark} ${c.provider.padEnd(11)} ${cols}${c.skip ? ` (skipped: ${c.skip})` : ""}`);
287
295
  }
288
296
  return;
@@ -301,7 +309,7 @@ async function main() {
301
309
  process.once("SIGINT", stop);
302
310
  for (const a of sbx.attempts.filter((a) => !a.ok))
303
311
  console.error(`! ${a.provider} failed, fell back: ${a.error}`);
304
- console.error(`> ${sbx.id} on ${sbx.provider} (~$${sbx.estimatedHourlyUsd}/hr, started in ${sbx.attempts.at(-1)?.ms} ms)`);
312
+ console.error(`> ${sbx.id} on ${sbx.provider} (~$${sbx.estimatedHourlyUsd}/hr${spec.gpu ? " excluding GPU charges" : ""}, started in ${sbx.attempts.at(-1)?.ms} ms)`);
305
313
  try {
306
314
  const r = await sbx.exec(command, {
307
315
  timeoutSeconds: 600,
@@ -321,9 +329,15 @@ async function main() {
321
329
  if (cmd === "check") {
322
330
  const ids = values.all ? router.registered().filter((id) => router.isConfigured(id)) : providers;
323
331
  if (!ids?.length) {
324
- if (values.all)
325
- return console.log("No providers configured: set at least one provider's keys (sandboxrouter providers lists them).");
326
- throw new RouterError("usage: sandboxrouter check --provider <id>[,<id>...] | --all");
332
+ if (!values.all)
333
+ throw new RouterError("usage: sandboxrouter check --provider <id>[,<id>...] | --all");
334
+ console.error("No providers configured: set at least one provider's keys (sandboxrouter providers lists them).");
335
+ if (values.out)
336
+ writeFileSync(values.out, "[]\n");
337
+ if (values.json)
338
+ console.log("[]");
339
+ process.exitCode = 1;
340
+ return;
327
341
  }
328
342
  const version = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
329
343
  const saveDir = values.save ? (rest[0] ?? "results/conformance") : undefined;
@@ -359,16 +373,16 @@ async function main() {
359
373
  writeFileSync(`${saveDir}/${p}.json`, JSON.stringify(saved, null, 2) + "\n");
360
374
  }
361
375
  }
376
+ const ran = reports.filter((r) => !r.inconclusive);
362
377
  if (values.out)
363
378
  writeFileSync(values.out, JSON.stringify(reports, null, 2) + "\n");
364
379
  if (values.json)
365
380
  console.log(JSON.stringify(reports, null, 2));
366
381
  else {
367
- const unpaid = reports.filter((r) => r.inconclusive).length;
368
- const ran = reports.length - unpaid;
369
- console.log(`\n${reports.filter((r) => r.ok).length}/${ran} passed${unpaid ? `; ${unpaid} not run (the account can't pay, or the provider's package isn't installed)` : ""}`);
382
+ const skipped = reports.length - ran.length;
383
+ console.log(`\n${ran.filter((r) => r.ok).length}/${ran.length} passed${skipped ? `; ${skipped} not run (the account can't pay, or the provider's package isn't installed)` : ""}`);
370
384
  }
371
- if (reports.some((r) => !r.ok && !r.inconclusive))
385
+ if (!ran.length || ran.some((r) => !r.ok))
372
386
  process.exitCode = 1;
373
387
  return;
374
388
  }
@@ -405,10 +419,22 @@ async function main() {
405
419
  }
406
420
  if (cmd === "agentbench") {
407
421
  const apiKey = process.env.GEMINI_API_KEY;
408
- if (!apiKey)
409
- return console.error("agentbench needs GEMINI_API_KEY (it stays on this machine; only shell commands reach the sandbox)");
422
+ if (!apiKey) {
423
+ console.error("agentbench needs GEMINI_API_KEY (it stays on this machine; only shell commands reach the sandbox)");
424
+ if (values.json)
425
+ console.log("[]");
426
+ process.exitCode = 1;
427
+ return;
428
+ }
410
429
  const model = values.model ?? "gemini-3.5-flash";
411
430
  const ids = providers ?? router.registered().filter((id) => router.isConfigured(id));
431
+ if (!ids.length) {
432
+ console.error("agentbench has no configured providers (sandboxrouter providers lists them).");
433
+ if (values.json)
434
+ console.log("[]");
435
+ process.exitCode = 1;
436
+ return;
437
+ }
412
438
  const rows = await agentBench({ router, providers: ids, runs: num(values.runs) ?? 5, apiKey, model, parallel: num(values.parallel), onProgress: (m) => console.error(m) });
413
439
  if (values.json)
414
440
  return console.log(JSON.stringify(rows, null, 2));
@@ -416,14 +442,8 @@ async function main() {
416
442
  console.log("| Provider | Done right | Wall | Waiting on model | Sandbox CPU | Turns | Sandbox cost |\n|---|---|---|---|---|---|---|");
417
443
  const s = (v) => (v === undefined ? "n/a" : `${(v / 1000).toFixed(1)} s`);
418
444
  for (const r of rows)
419
- 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)}`} |`);
445
+ console.log(`| ${r.provider} | ${r.ok}/${r.requested ?? r.runs}${r.limited ? ` (${r.limited} refused)` : ""} | ${s(r.medianWallMs)} | ${s(r.medianModelMs)} | ${s(r.medianCpuMs)} | ${r.medianTurns ?? "n/a"} | ${r.medianUsd === undefined ? "n/a" : `$${r.medianUsd.toFixed(6)}`} |`);
420
446
  if (values.share || values.submit) {
421
- const started = rows.filter((r) => r.medianWallMs !== undefined);
422
- if (rows.length - started.length >= 3) {
423
- 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.`);
424
- process.exitCode = 1;
425
- return;
426
- }
427
447
  const version = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
428
448
  const report = {
429
449
  tool: "sandboxrouter-agent",
@@ -436,7 +456,7 @@ async function main() {
436
456
  runs: num(values.runs) ?? 5,
437
457
  node: process.version,
438
458
  platform: `${platform()}-${arch()}`,
439
- rows: started.filter((r) => benchmarksPublishable(r.provider)),
459
+ rows: rows.filter((r) => benchmarksPublishable(r.provider)),
440
460
  };
441
461
  const file = values.out ?? `sandboxrouter-agent-${report.date.slice(0, 10)}-${Math.random().toString(36).slice(2, 8)}.json`;
442
462
  writeFileSync(file, JSON.stringify(report, null, 2) + "\n");
@@ -480,14 +500,12 @@ async function main() {
480
500
  if (values.json)
481
501
  return console.log(JSON.stringify(rows, null, 2));
482
502
  console.log(`\nsandboxrouter burst: ${n} at once${job ? `, each running the ${job} job` : ""}\n`);
483
- console.log("| Provider | Started | p50 | p95 | p99 | All done | Burst cost |\n|---|---|---|---|---|---|---|");
503
+ console.log(`| Provider | ${job ? "Completed jobs" : "Ready"} | p50 ready | p95 ready | p99 ready | Last outcome | Est. cost of successes |\n|---|---|---|---|---|---|---|`);
484
504
  for (const r of rows) {
485
505
  const ms = (v) => (v === undefined ? "n/a" : `${v} ms`);
486
506
  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)}`} |`);
487
507
  }
488
508
  if (values.share || values.submit) {
489
- // As with bench: nothing from a run where this machine lost its connection, and no provider that never answered.
490
- const shared = rows.filter((r) => r.ok > 0 || r.limited > 0);
491
509
  const version = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
492
510
  const report = {
493
511
  tool: "sandboxrouter-burst",
@@ -499,13 +517,8 @@ async function main() {
499
517
  ...(job ? { task: TASKS[job].version } : {}),
500
518
  node: process.version,
501
519
  platform: `${platform()}-${arch()}`,
502
- rows: shared.filter((r) => benchmarksPublishable(r.provider)),
520
+ rows: rows.filter((r) => benchmarksPublishable(r.provider)),
503
521
  };
504
- if (rows.length - shared.length >= 3) {
505
- console.error(`\nnot writing a report: ${rows.length - shared.length} providers started nothing, which looks like this machine lost its connection. Run it again.`);
506
- process.exitCode = 1;
507
- return;
508
- }
509
522
  const file = values.out ?? `sandboxrouter-burst-${report.date.slice(0, 10)}-${Math.random().toString(36).slice(2, 8)}.json`;
510
523
  writeFileSync(file, JSON.stringify(report, null, 2) + "\n");
511
524
  if (values.submit) {
@@ -552,12 +565,7 @@ async function main() {
552
565
  }
553
566
  else if (values.share || values.submit) {
554
567
  const version = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
555
- // A provider whose every run failed on the submitter's own account (bad key, no credit, a limit hit) says
556
- // nothing about the provider: leave it out of what's shared, and say so.
557
- const account = rows.filter((r) => r.failures === r.runs && r.lastError && ACCOUNT_ERROR.test(r.lastError));
558
- if (account.length)
559
- console.error(`\nleft out of the shared report, every run failed on your account: ${account.map((r) => r.provider).join(", ")}`);
560
- 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 });
568
+ 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 });
561
569
  const left = rows.filter((r) => !benchmarksPublishable(r.provider)).map((r) => r.provider);
562
570
  if (left.length)
563
571
  console.log(`\nleft out of the shared report: ${left.join(", ")} (their terms don't allow publishing benchmarks)`);
@@ -119,7 +119,7 @@ export declare class RoutedComputer {
119
119
  screenshot(opts?: {
120
120
  format?: "png" | "jpeg";
121
121
  quality?: number;
122
- }): Promise<Uint8Array<ArrayBufferLike>>;
122
+ }): Promise<Uint8Array>;
123
123
  /** Run a shell command (max 30 s). The second argument is `{ timeoutSeconds }`, or the number alone. */
124
124
  exec(command: string, opts?: number | {
125
125
  timeoutSeconds?: number;
@@ -128,7 +128,7 @@ export declare class RoutedComputer {
128
128
  stdout: string;
129
129
  stderr: string;
130
130
  }>;
131
- readFile(path: string): Promise<Uint8Array<ArrayBufferLike>>;
131
+ readFile(path: string): Promise<Uint8Array>;
132
132
  writeFile(path: string, content: string | Uint8Array): Promise<void>;
133
133
  /** What this computer's provider supports beyond the core actions. */
134
134
  get supports(): {
@@ -1,5 +1,6 @@
1
1
  import { type PhaseMs } from "./task.js";
2
2
  import type { BenchRow } from "./bench.js";
3
+ import { type Size } from "./router.js";
3
4
  import type { ProviderId, SandboxSpec } from "./types.js";
4
5
  /**
5
6
  * A shareable bench result. People submit these as PRs to results/, and `sandboxrouter
@@ -37,6 +38,7 @@ export interface LeaderRow {
37
38
  submissions: number;
38
39
  medianCreateMs?: number;
39
40
  medianExecMs?: number;
41
+ medianReadyMs?: number;
40
42
  successRate: number;
41
43
  /** Runs behind the row that the provider was asked to do (refusals for an account limit left out). */
42
44
  runs: number;
@@ -56,7 +58,7 @@ export interface LeaderRow {
56
58
  * the one with the most runs wins (a 100-run start-time benchmark over a 3-run job that also timed starts);
57
59
  * ties go to the newest.
58
60
  */
59
- export declare function aggregate(reports: BenchReport[]): LeaderRow[];
61
+ export declare function aggregate(reports: BenchReport[], cohort?: Size): LeaderRow[];
60
62
  export interface TaskRow {
61
63
  provider: ProviderId;
62
64
  name: string;
@@ -74,8 +76,10 @@ export interface TaskRow {
74
76
  taskUsd: number;
75
77
  /** What one job costs in a sandbox that's already running (no start, minimum or per-sandbox fee). */
76
78
  reusedUsd: number;
77
- /** Runs behind the medians (refusals for an account limit left out). */
79
+ /** All requests in the comparison, including failed starts and limits. */
78
80
  runs: number;
81
+ ok: number;
82
+ limited: number;
79
83
  /** Share of those runs that finished the job. */
80
84
  successRate: number;
81
85
  /** CPU time the task used across all vCPUs (median), where the sandbox shows /proc/stat. */
@@ -86,12 +90,16 @@ export interface TaskRow {
86
90
  perSandboxUsd: number;
87
91
  measuredAt: string;
88
92
  }
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[];
93
+ export declare function taskOutcomes(reports: BenchReport[], version: string, cohort?: Size): {
94
+ provider: ProviderId;
95
+ name: string;
96
+ requested: number;
97
+ completed: number;
98
+ limited: number;
99
+ failures: number;
100
+ taskFailures: number;
101
+ }[];
102
+ export declare function taskTable(reports: BenchReport[], version?: string, cohort?: Size): TaskRow[];
95
103
  /** One self-contained HTML page: a sorted table with an inline bar per measure, each on its own scale. */
96
104
  export declare function renderLeaderboard(reports: BenchReport[]): string;
97
105
  /** A saved `sandboxrouter burst` report (results/, tool "sandboxrouter-burst"). */
@@ -119,6 +127,14 @@ export declare function burstTable(reports: BurstReport[], task?: string, n?: nu
119
127
  n: number;
120
128
  ok: number;
121
129
  limited: number;
130
+ size?: {
131
+ vcpu: number;
132
+ memoryGb: number;
133
+ };
134
+ createFailures?: number;
135
+ commandFailures?: number;
136
+ taskFailures?: number;
137
+ cleanupFailures?: number;
122
138
  p50Ms?: number;
123
139
  p95Ms?: number;
124
140
  p99Ms?: number;
@@ -144,6 +160,12 @@ export declare function loadAgentReports(dir: string): AgentReport[];
144
160
  export declare function agentTable(reports: AgentReport[]): {
145
161
  provider: ProviderId;
146
162
  runs: number;
163
+ requested?: number;
164
+ started?: number;
165
+ size?: {
166
+ vcpu: number;
167
+ memoryGb: number;
168
+ };
147
169
  limited?: number;
148
170
  ok: number;
149
171
  medianWallMs?: number;
@@ -1,9 +1,17 @@
1
1
  import { readdirSync, readFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
- import { benchmarksPublishable, billingRules, CATALOG, cpuHourlyAtFull, fittingSpec, hourlyCost } from "./catalog.js";
3
+ import { benchmarksPublishable, billingRules, CATALOG, cpuHourlyAtFull, hourlyCost } from "./catalog.js";
4
4
  import { BILLED_VS_LIST } from "./billing.js";
5
- import { TASK_VERSION, taskByVersion, taskUsd } from "./task.js";
5
+ import { AGENT_TASK_VERSION } from "./agent-bench.js";
6
+ import { isCurrentTask, TASK_VERSION, taskByVersion, taskUsd } from "./task.js";
6
7
  import { median } from "./bench-store.js";
8
+ import { sizeOf } from "./router.js";
9
+ const sameSize = (a, b) => a.vcpu === b.vcpu && a.memoryGb === b.memoryGb;
10
+ const DEFAULT_SIZE = { vcpu: 2, memoryGb: 4 };
11
+ const requestedSize = (spec) => ({
12
+ vcpu: spec.vcpu ?? DEFAULT_SIZE.vcpu,
13
+ memoryGb: spec.memoryGb ?? DEFAULT_SIZE.memoryGb,
14
+ });
7
15
  export function makeReport(rows, opts) {
8
16
  return {
9
17
  tool: "sandboxrouter",
@@ -49,17 +57,18 @@ const KNOWN = new Set(CATALOG.map((c) => c.id));
49
57
  * the one with the most runs wins (a 100-run start-time benchmark over a 3-run job that also timed starts);
50
58
  * ties go to the newest.
51
59
  */
52
- export function aggregate(reports) {
60
+ export function aggregate(reports, cohort = DEFAULT_SIZE) {
61
+ const comparable = reports.filter((r) => sameSize(requestedSize(r.spec ?? {}), cohort));
53
62
  const latest = new Map();
54
63
  const newest = new Map();
55
- for (const rep of reports)
64
+ for (const rep of comparable)
56
65
  for (const r of rep.rows) {
57
66
  const key = `${r.provider}\u0000${rep.label ?? ""}`;
58
67
  if ((newest.get(key) ?? "") < rep.date)
59
68
  newest.set(key, rep.date);
60
69
  }
61
70
  const MONTH = 30 * 86_400_000;
62
- for (const rep of reports) {
71
+ for (const rep of comparable) {
63
72
  for (const r of rep.rows) {
64
73
  if (!KNOWN.has(r.provider))
65
74
  continue;
@@ -75,7 +84,10 @@ export function aggregate(reports) {
75
84
  for (const x of latest.values())
76
85
  by.set(x.row.provider, [...(by.get(x.row.provider) ?? []), x]);
77
86
  const rows = [...by.entries()].map(([id, xs]) => {
78
- const rs = xs.map((x) => x.row);
87
+ const latestRow = xs.reduce((a, b) => a.date >= b.date ? a : b).row;
88
+ const size = latestRow.size ?? sizeOf(id, cohort);
89
+ const matching = xs.filter(({ row }) => sameSize(row.size ?? sizeOf(id, cohort), size));
90
+ const rs = matching.map((x) => x.row);
79
91
  const runs = rs.reduce((n, r) => n + r.runs, 0);
80
92
  const ok = rs.reduce((n, r) => n + (r.runs - r.failures), 0);
81
93
  // Refusals for a limit on the benchmarking account aren't the provider failing: leave them out of the rate.
@@ -86,11 +98,12 @@ export function aggregate(reports) {
86
98
  submissions: rs.length,
87
99
  medianCreateMs: median(rs.map((r) => r.medianCreateMs).filter((n) => typeof n === "number")),
88
100
  medianExecMs: median(rs.map((r) => r.medianExecMs).filter((n) => typeof n === "number")),
101
+ medianReadyMs: rs.every((r) => r.medianReadyMs !== undefined) ? median(rs.map((r) => r.medianReadyMs)) : undefined,
89
102
  successRate: attempted ? ok / attempted : 0,
90
103
  runs: attempted,
91
- hourlyUsd: hourlyCost(id, fittingSpec(id)),
92
- size: fittingSpec(id),
93
- measuredAt: xs.map((x) => x.date).sort().at(-1),
104
+ hourlyUsd: hourlyCost(id, size),
105
+ size,
106
+ measuredAt: matching.map((x) => x.date).sort().at(-1),
94
107
  };
95
108
  });
96
109
  return rows.sort((a, b) => (a.medianCreateMs ?? Infinity) - (b.medianCreateMs ?? Infinity));
@@ -100,16 +113,15 @@ export function aggregate(reports) {
100
113
  * `version` (the short task's by default; TASKS.long.version for `--long`): each provider's latest run
101
114
  * from each location, then the median across locations (as `aggregate` does). Cheapest task first.
102
115
  */
103
- export function taskTable(reports, version = TASK_VERSION) {
104
- const def = taskByVersion(version);
105
- if (!def)
106
- return [];
116
+ function currentTaskRows(reports, version, cohort) {
107
117
  const latest = new Map();
118
+ if (!isCurrentTask(version))
119
+ return new Map();
108
120
  for (const rep of reports) {
109
- if (rep.task !== version)
121
+ if (rep.task !== version || !sameSize(requestedSize(rep.spec ?? {}), cohort))
110
122
  continue;
111
123
  for (const r of rep.rows) {
112
- if (!KNOWN.has(r.provider) || !r.taskPhasesMs || r.medianTaskMs === undefined || r.medianCreateMs === undefined)
124
+ if (!KNOWN.has(r.provider) || r.size === undefined || r.taskOk === undefined)
113
125
  continue;
114
126
  const key = `${r.provider}\u0000${rep.label ?? ""}`;
115
127
  const seen = latest.get(key);
@@ -120,45 +132,71 @@ export function taskTable(reports, version = TASK_VERSION) {
120
132
  const by = new Map();
121
133
  for (const x of latest.values())
122
134
  by.set(x.row.provider, [...(by.get(x.row.provider) ?? []), x]);
123
- const rows = [...by.entries()].map(([id, xs]) => {
135
+ // Keep a provider's region samples comparable when its default shape changes between reports.
136
+ for (const [id, xs] of by) {
137
+ const newest = xs.reduce((a, b) => a.date >= b.date ? a : b);
138
+ by.set(id, xs.filter((x) => sameSize(x.row.size, newest.row.size)));
139
+ }
140
+ return by;
141
+ }
142
+ export function taskOutcomes(reports, version, cohort = DEFAULT_SIZE) {
143
+ return [...currentTaskRows(reports, version, cohort)].map(([provider, xs]) => ({
144
+ provider,
145
+ name: CATALOG.find((c) => c.id === provider).name,
146
+ requested: xs.reduce((n, x) => n + x.row.runs, 0),
147
+ completed: xs.reduce((n, x) => n + x.row.taskOk, 0),
148
+ limited: xs.reduce((n, x) => n + (x.row.limited ?? 0), 0),
149
+ failures: xs.reduce((n, x) => n + x.row.failures - (x.row.limited ?? 0), 0),
150
+ taskFailures: xs.reduce((n, x) => n + x.row.runs - x.row.failures - x.row.taskOk, 0),
151
+ }));
152
+ }
153
+ export function taskTable(reports, version = TASK_VERSION, cohort = DEFAULT_SIZE) {
154
+ const def = taskByVersion(version);
155
+ if (!def || !isCurrentTask(version))
156
+ return [];
157
+ const rows = [...currentTaskRows(reports, version, cohort)].flatMap(([id, xs]) => {
124
158
  const rs = xs.map((x) => x.row);
125
- const createMs = median(rs.map((r) => r.medianCreateMs));
126
- const taskMillis = median(rs.map((r) => r.medianTaskMs));
127
- const phasesMs = Object.fromEntries(def.phases.map((p) => [p.id, median(rs.map((r) => r.taskPhasesMs[p.id]))]));
159
+ const successful = rs.filter((r) => r.taskOk > 0 && r.taskPhasesMs && r.medianTaskMs !== undefined && r.medianTaskReadyMs !== undefined);
160
+ if (!successful.length)
161
+ return [];
162
+ const createMs = median(successful.map((r) => r.medianTaskReadyMs));
163
+ const taskMillis = median(successful.map((r) => r.medianTaskMs));
164
+ const phasesMs = Object.fromEntries(def.phases.map((p) => [p.id, median(successful.map((r) => r.taskPhasesMs[p.id]))]));
128
165
  // The job's own CPU hint (the agent loop's 10%) prices it the way its sandboxes were started.
129
- const size = { ...fittingSpec(id), ...(def.cpuUtilization ? { cpuUtilization: def.cpuUtilization } : {}) };
166
+ const size = { ...rs[0].size, ...(def.cpuUtilization ? { cpuUtilization: def.cpuUtilization } : {}) };
130
167
  const ratio = BILLED_VS_LIST[id]?.ratio ?? 1;
131
- const hourlyUsd = hourlyCost(id, fittingSpec(id)) * ratio;
168
+ const hourlyUsd = hourlyCost(id, size) * ratio;
132
169
  const rules = billingRules(id);
133
- const cpus = rs.map((r) => r.medianTaskCpuMs).filter((n) => typeof n === "number");
170
+ const cpus = successful.map((r) => r.medianTaskCpuMs).filter((n) => typeof n === "number");
134
171
  // A container can show the whole host's /proc/stat (Daytona does): a reading beyond what the sandbox's
135
172
  // own vCPUs could do in that time isn't the sandbox's, so it's dropped and the task is priced at full CPU.
136
- const read = cpus.length === rs.length ? median(cpus) : undefined;
173
+ const read = cpus.length === successful.length ? median(cpus) : undefined;
137
174
  const cpuMs = read !== undefined && read <= size.vcpu * taskMillis * 1.1 ? read : undefined;
138
- const cores = rs.map((r) => r.medianTaskMaxCoreMs).filter((n) => typeof n === "number");
139
- const coreRead = cores.length === rs.length ? median(cores) : undefined;
175
+ const cores = successful.map((r) => r.medianTaskMaxCoreMs).filter((n) => typeof n === "number");
176
+ const coreRead = cores.length === successful.length ? median(cores) : undefined;
140
177
  const maxCoreMs = cpuMs !== undefined && coreRead !== undefined && coreRead <= taskMillis * 1.1 ? coreRead : undefined;
141
- return {
142
- provider: id,
143
- name: CATALOG.find((c) => c.id === id).name,
144
- size,
145
- createMs,
146
- taskMs: taskMillis,
147
- phasesMs,
148
- hourlyUsd,
149
- taskUsd: taskUsd(id, size, createMs, taskMillis, cpuMs, ratio, false, maxCoreMs),
150
- reusedUsd: taskUsd(id, size, createMs, taskMillis, cpuMs, ratio, true, maxCoreMs),
151
- runs: rs.reduce((n, r) => n + r.runs - (r.limited ?? 0), 0),
152
- successRate: (() => {
153
- const tried = rs.reduce((n, r) => n + r.runs - (r.limited ?? 0), 0);
154
- return tried ? rs.reduce((n, r) => n + r.runs - r.failures, 0) / tried : 0;
155
- })(),
156
- ...(cpuMs !== undefined ? { cpuMs } : {}),
157
- activeCpu: cpuHourlyAtFull(id, size) > 0,
158
- minimumSeconds: rules.minSeconds,
159
- perSandboxUsd: rules.perSandboxUsd,
160
- measuredAt: xs.map((x) => x.date).sort().at(-1),
161
- };
178
+ const runs = rs.reduce((n, r) => n + r.runs, 0);
179
+ const ok = rs.reduce((n, r) => n + r.taskOk, 0);
180
+ return [{
181
+ provider: id,
182
+ name: CATALOG.find((c) => c.id === id).name,
183
+ size,
184
+ createMs,
185
+ taskMs: taskMillis,
186
+ phasesMs,
187
+ hourlyUsd,
188
+ taskUsd: taskUsd(id, size, createMs, taskMillis, cpuMs, ratio, false, maxCoreMs),
189
+ reusedUsd: taskUsd(id, size, createMs, taskMillis, cpuMs, ratio, true, maxCoreMs),
190
+ runs,
191
+ ok,
192
+ limited: rs.reduce((n, r) => n + (r.limited ?? 0), 0),
193
+ successRate: runs ? ok / runs : 0,
194
+ ...(cpuMs !== undefined ? { cpuMs } : {}),
195
+ activeCpu: cpuHourlyAtFull(id, size) > 0,
196
+ minimumSeconds: rules.minSeconds,
197
+ perSandboxUsd: rules.perSandboxUsd,
198
+ measuredAt: xs.map((x) => x.date).sort().at(-1),
199
+ }];
162
200
  });
163
201
  return rows.sort((a, b) => a.taskUsd - b.taskUsd || a.provider.localeCompare(b.provider));
164
202
  }
@@ -318,9 +356,6 @@ export function burstTable(reports, task, n) {
318
356
  if (n !== undefined && rep.n !== n)
319
357
  continue;
320
358
  for (const r of rep.rows) {
321
- // Nothing started (an account blocked outright): nothing measured.
322
- if (r.ok === 0)
323
- continue;
324
359
  if (!KNOWN.has(r.provider) || !benchmarksPublishable(r.provider))
325
360
  continue;
326
361
  const seen = latest.get(r.provider);
@@ -356,7 +391,11 @@ export function loadAgentReports(dir) {
356
391
  /** Each provider's latest real-agent result: done right first, then cheapest sandbox per session. */
357
392
  export function agentTable(reports) {
358
393
  const latest = new Map();
394
+ const current = reports.filter((r) => r.task === AGENT_TASK_VERSION);
395
+ const cohort = current.reduce((a, b) => !a || b.date > a.date ? b : a, undefined);
359
396
  for (const rep of reports) {
397
+ if (rep.task !== AGENT_TASK_VERSION || rep.model !== cohort?.model)
398
+ continue;
360
399
  for (const r of rep.rows) {
361
400
  if (!KNOWN.has(r.provider) || !benchmarksPublishable(r.provider))
362
401
  continue;
@@ -367,5 +406,5 @@ export function agentTable(reports) {
367
406
  }
368
407
  return [...latest.values()]
369
408
  .map(({ row, date, model }) => ({ ...row, name: CATALOG.find((c) => c.id === row.provider).name, measuredAt: date, model }))
370
- .sort((a, b) => b.ok / b.runs - a.ok / a.runs || (a.medianUsd ?? Infinity) - (b.medianUsd ?? Infinity));
409
+ .sort((a, b) => b.ok / Math.max(1, b.requested ?? b.runs) - a.ok / Math.max(1, a.requested ?? a.runs) || (a.medianUsd ?? Infinity) - (b.medianUsd ?? Infinity));
371
410
  }
@@ -1,9 +1,9 @@
1
1
  import type { ProviderId } from "./types.js";
2
2
  /**
3
3
  * The price index: what a few standard pieces of sandbox work cost today across the providers that passed
4
- * the real-account check. Each line is the median of what the router would charge on each of them (list
5
- * price, corrected by measured bills, with minimum charges and per-sandbox fees over the run), plus the
6
- * cheapest. It moves only when a provider's price in the catalog changes.
4
+ * the real-account check. Each line shows the median and lowest estimated direct-provider cost (list
5
+ * price, corrected by measured bills, with minimum charges and modeled per-sandbox fees over the run).
6
+ * Account-specific fees, such as Boat's allowance overages, are excluded.
7
7
  */
8
8
  export declare const INDEX_LINES: readonly [{
9
9
  readonly id: "2x4-hour";
@@ -4,9 +4,9 @@ import { Router, rankUsd, runHours } from "./router.js";
4
4
  import { VERIFIED } from "./verified.js";
5
5
  /**
6
6
  * The price index: what a few standard pieces of sandbox work cost today across the providers that passed
7
- * the real-account check. Each line is the median of what the router would charge on each of them (list
8
- * price, corrected by measured bills, with minimum charges and per-sandbox fees over the run), plus the
9
- * cheapest. It moves only when a provider's price in the catalog changes.
7
+ * the real-account check. Each line shows the median and lowest estimated direct-provider cost (list
8
+ * price, corrected by measured bills, with minimum charges and modeled per-sandbox fees over the run).
9
+ * Account-specific fees, such as Boat's allowance overages, are excluded.
10
10
  */
11
11
  export const INDEX_LINES = [
12
12
  { id: "2x4-hour", label: "2 vCPU / 4 GB, one hour", unit: "per hour", spec: { vcpu: 2, memoryGb: 4, timeoutMinutes: 60 }, scale: 1 },
@@ -53,8 +53,11 @@ export class DockerProvider {
53
53
  }
54
54
  async connect(nativeId) {
55
55
  const r = await run(this.bin, ["inspect", "-f", "{{.State.Status}}", nativeId]);
56
- if (r.code !== 0)
57
- throw new ProviderError("docker", `no container ${nativeId}`, 404);
56
+ if (r.code !== 0) {
57
+ if (containerAbsent(r.stderr))
58
+ throw new ProviderError("docker", `no container ${nativeId}`, 404);
59
+ throw new ProviderError("docker", `inspect failed: ${r.stderr.trim().slice(0, 300)}`);
60
+ }
58
61
  if (r.stdout.trim() === "paused")
59
62
  await run(this.bin, ["unpause", nativeId]);
60
63
  return new DockerBox(this.bin, nativeId);
@@ -103,9 +106,16 @@ class DockerBox {
103
106
  throw new ProviderError("docker", `pause failed: ${r.stderr.trim()}`);
104
107
  }
105
108
  async kill() {
106
- await run(this.bin, ["rm", "-f", this.nativeId]);
109
+ const r = await run(this.bin, ["rm", "-f", this.nativeId]);
110
+ if (r.code !== 0 && !containerAbsent(r.stderr)) {
111
+ throw new ProviderError("docker", `docker rm failed: ${r.stderr.trim().slice(0, 300)}`);
112
+ }
107
113
  }
108
114
  }
115
+ /** Only an explicit daemon response confirms that the container is gone. */
116
+ function containerAbsent(stderr) {
117
+ return /^(?:Error(?: response from daemon)?: )?No such (?:container|object): /im.test(stderr);
118
+ }
109
119
  function run(bin, args, opts = {}) {
110
120
  const t0 = Date.now();
111
121
  return new Promise((resolve, reject) => {
@@ -57,21 +57,14 @@ export declare class LimrunProvider implements ComputerProvider {
57
57
  baseURL?: string;
58
58
  });
59
59
  configured(): boolean;
60
- /** @internal */
61
- client(): Promise<{
62
- mod: LimrunModule;
63
- lim: LimrunClient;
64
- }>;
60
+ private client;
65
61
  createComputer(spec: ComputerSpec): Promise<ProviderComputer>;
66
62
  /** Limrun ids don't say which platform they belong to, so try Android, then iOS. */
67
63
  connectComputer(nativeId: string): Promise<ProviderComputer>;
68
64
  }
69
- type LimrunModule = typeof import("@limrun/api");
70
- type LimrunClient = InstanceType<LimrunModule["Limrun"]>;
71
65
  /** @internal "ctrl+Return" on android -> { key: "ENTER", modifiers: ["ctrl"] }. Throws if unavailable. */
72
66
  export declare function limrunKey(chord: string, os: "android" | "ios"): {
73
67
  key: string;
74
68
  modifiers: string[];
75
69
  button?: string;
76
70
  };
77
- export {};
@@ -60,7 +60,6 @@ export class LimrunProvider {
60
60
  configured() {
61
61
  return !!this.apiKey;
62
62
  }
63
- /** @internal */
64
63
  client() {
65
64
  if (!this.apiKey)
66
65
  return Promise.reject(err("LIM_API_KEY is not set"));
@@ -1,6 +1,4 @@
1
1
  import type { ComputerOs, ComputerProvider, ComputerSpec, ProviderComputer } from "../computers.js";
2
- type MobilerunModule = typeof import("@mobilerun/sdk");
3
- type MobilerunClient = InstanceType<MobilerunModule["Mobilerun"]>;
4
2
  /**
5
3
  * Mobilerun (droidrun) cloud Android phones via `@mobilerun/sdk`. Desktop-only: no sandboxes.
6
4
  *
@@ -25,8 +23,7 @@ export declare class MobilerunProvider implements ComputerProvider {
25
23
  /** The SDK reads MOBILERUN_CLOUD_API_KEY itself; we read it too so configured() is honest. */
26
24
  constructor(apiKey?: string | undefined, baseURL?: string | undefined);
27
25
  configured(): boolean;
28
- /** @internal */
29
- sdk(): Promise<MobilerunClient>;
26
+ private sdk;
30
27
  createComputer(spec: ComputerSpec): Promise<ProviderComputer>;
31
28
  /** Re-attach by device id. A parked (stopped) phone is resumed and waited on. */
32
29
  connectComputer(nativeId: string): Promise<ProviderComputer>;
@@ -41,4 +38,3 @@ export declare class MobilerunProvider implements ComputerProvider {
41
38
  export declare const MOBILERUN_KEYS: Record<string, number>;
42
39
  /** One xdotool key name (no modifiers) to an Android key code. */
43
40
  export declare function mobilerunKey(name: string): number;
44
- export {};