@sandboxrouter/sdk 0.20.0 → 0.21.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # sandboxRouter
2
2
 
3
- **One API for every sandbox.** A free, open-source router for the places an AI agent can run code: Agent37, Alibaba Cloud, AWS (Bedrock AgentCore and Lambda MicroVMs), Azure Container Apps, Beam, Blaxel, Boat, Cloudflare, CodeSandbox, Daytona, Dedalus Machines, Deno, DigitalOcean Harness Runtime, E2B, exe.dev, Fly.io Sprites, Freestyle, Google Cloud Agent Platform, HOPX, InstaBox, Koyeb, Maritime, Modal, Morph, Northflank, Novita, OpenScale, Run Cloud, Runloop, Sail, Superserve, Tensorlake, Upstash Box and Vercel, plus Docker on your own machine. It picks a provider by price, speed or capability, and falls back to the next one when a provider is down or rate-limited.
3
+ **One API for every sandbox.** A free, open-source router for the places an AI agent can run code: <!-- providers:start -->36 hosted providers (Agent37, Alibaba Cloud Agent Sandbox, Amazon Bedrock AgentCore Code Interpreter, AWS Lambda MicroVMs, Azure Container Apps dynamic sessions, Beam, Blaxel, Boat, Cloudflare, CodeSandbox SDK, Daytona, Dedalus Machines, Deno, DigitalOcean Harness Runtime, E2B, exe.dev, Fly.io Sprites, Freestyle, Google Cloud Agent Platform, HOPX, InstaBox, Koyeb, LangSmith, Maritime, Modal, Morph Cloud, Northflank, Novita, OpenScale, Run Cloud, Runloop, Sailboxes, Superserve, Tensorlake, Upstash Box, Vercel)<!-- providers:end -->, plus Docker on your own machine. It picks a provider by price, speed or capability, and falls back to the next one when a provider is down or rate-limited.
4
4
 
5
5
  E2B quickstart (Node 22.19+ and an E2B API key):
6
6
 
@@ -26,7 +26,7 @@ try {
26
26
 
27
27
  The SDK uses ES modules and runs on Node 20+. Each optional provider SDK can require a newer Node version. For TypeScript 5.2+ on Node 22+, `await using sbx = ...` also works when the compiler includes `ESNext.Disposable`. Plain JavaScript supports that syntax on Node 24+.
28
28
 
29
- Set the keys of the providers you use. `create()` starts the sandbox on the cheapest one that fits: list price for the size you asked for, corrected where we measured what a provider really bills. Providers within 10% of each other on estimated price go fastest first. The router uses its own timings, your benchmark file or published timings, in that order. Estimates exclude account-specific charges such as [Boat’s fees above its included start allowance](https://docs.boat.dev/limits.md#extra-starts). Providers that failed their last real-account check go last. Ties are alphabetical, and no provider pays for placement. If that provider is down, busy or out of credit, the next one takes it, and every attempt is on `sbx.attempts`. The sandbox stays on that provider until you `kill()` it.
29
+ Set the keys of the providers you use. `create()` starts the sandbox on the cheapest one that fits: list price for the size you asked for, corrected by measured usage for the few providers where a billing API gave a precise figure (`src/billing.ts`; today one). Providers within 10% of each other on estimated price go fastest first. The router uses its own timings, your benchmark file or published timings, in that order. Estimates exclude account-specific charges such as [Boat’s fees above its included start allowance](https://docs.boat.dev/limits.md#extra-starts). Providers that failed their last real-account check go last. Ties are alphabetical, and no provider pays for placement. If that provider is down, busy or out of credit, the next one takes it, and every attempt is on `sbx.attempts`. The sandbox stays on that provider until you `kill()` it.
30
30
 
31
31
  Site and docs: [sandboxrouter.ai](https://sandboxrouter.ai) · npm: [`@sandboxrouter/sdk`](https://www.npmjs.com/package/@sandboxrouter/sdk)
32
32
 
@@ -44,47 +44,47 @@ AI agents need a disposable computer to run code a model wrote: install packages
44
44
 
45
45
  ## Prices
46
46
 
47
- List price while running, 2 vCPU / 4 GB, cheapest first; waitlisted sign-ups follow. The router ranks by these, corrected where we measured what a provider really bills, and tries providers whose last real-account check failed last. "Up to" = CPU billed only while busy, shown with every core busy. "Not run yet" = built from the provider's docs and tested against mocks only. Click a provider for its billing details; more in [Reading the price table](https://sandboxrouter.ai/docs#price-table).
47
+ List price while running, 2 vCPU / 4 GB, cheapest first; waitlisted sign-ups follow. The router ranks by these, corrected by measured usage for the few providers that have a precise figure (`src/billing.ts`), and tries providers whose last real-account check failed last. "Up to" = CPU billed only while busy, shown with every core busy. "From your own image" = the provider's default image is smaller, so the price is for 2 vCPU / 4 GB started from your own image or template, and the router skips that provider at this size until you name one (`image.<provider>`). A size in brackets = the provider only sells fixed sizes, and the price is for the smallest that fits. "Not run yet" = built from the provider's docs and tested against mocks only. Click a provider for its billing details; more in [Reading the price table](https://sandboxrouter.ai/docs#price-table).
48
48
 
49
49
  | Provider | $/hr | Plan needed | Real-account check | Source |
50
50
  |---|---|---|---|---|
51
- | [Agent37](https://sandboxrouter.ai/providers/agent37) | $0.007 | none | passed (2026-11-13) | [pricing](https://www.agent37.com/docs/agents-api/billing) |
52
- | [Boat](https://sandboxrouter.ai/providers/boat) | $0.018 | $20/mo (credited) | passed (2026-11-14) | [pricing](https://docs.boat.dev/pricing.md) |
53
- | [Maritime](https://sandboxrouter.ai/providers/maritime) | $0.022 | $20/mo (credited) | passed (2026-11-13) | [pricing](https://maritime.sh/pricing) |
51
+ | [Agent37](https://sandboxrouter.ai/providers/agent37) | $0.007 | none | passed, last checked 2026-11-13 | [pricing](https://www.agent37.com/docs/agents-api/billing) |
52
+ | [OpenScale Sandboxes](https://sandboxrouter.ai/providers/openscale) | $0.017 (from your own image; the default image is 2 vCPU / 1 GB) | none | passed, last checked 2026-11-13 | [pricing](https://openscale.so/sandboxes) |
53
+ | [Boat](https://sandboxrouter.ai/providers/boat) | $0.018 | $20/mo (credited) | passed, last checked 2026-11-14; changed in 0.17.0, not re-checked | [pricing](https://docs.boat.dev/pricing.md) |
54
+ | [Maritime](https://sandboxrouter.ai/providers/maritime) | $0.022 | $20/mo (credited) | passed, last checked 2026-11-13 | [pricing](https://maritime.sh/pricing) |
54
55
  | [Run Cloud](https://sandboxrouter.ai/providers/runcloud) | $0.030 | none | not run yet | [pricing](https://run.cloud/pricing) |
55
- | [Sailboxes (Sail Research)](https://sandboxrouter.ai/providers/sail) | up to $0.062 | none | passed (2026-11-14) | [pricing](https://docs.sailresearch.com/sailboxes-pricing.md) |
56
- | [Northflank](https://sandboxrouter.ai/providers/northflank) | $0.067 | none | passed (2026-11-18) | [pricing](https://northflank.com/pricing) |
57
- | [Morph Cloud](https://sandboxrouter.ai/providers/morph) | $0.100 | none | passed (2026-11-18) | [pricing](https://cloud.morph.so/web/pricing) |
56
+ | [Sailboxes (Sail Research)](https://sandboxrouter.ai/providers/sail) | up to $0.062 | none | passed, last checked 2026-11-14 | [pricing](https://docs.sailresearch.com/sailboxes-pricing.md) |
57
+ | [Northflank](https://sandboxrouter.ai/providers/northflank) | $0.067 | none | passed, last checked 2026-11-18; changed in 0.18.0, not re-checked | [pricing](https://northflank.com/pricing) |
58
+ | [Morph Cloud](https://sandboxrouter.ai/providers/morph) | $0.100 | none | passed, last checked 2026-11-18 | [pricing](https://cloud.morph.so/web/pricing) |
58
59
  | [exe.dev](https://sandboxrouter.ai/providers/exedev) | $0.105 | $15/mo | not run yet | [pricing](https://exe.dev/docs/standalone-vms.md) |
60
+ | [Novita AI Agent Sandbox](https://sandboxrouter.ai/providers/novita) | $0.117 (from your own image; the default image is 2 vCPU / 1 GB) | none | passed, last checked 2026-11-13; changed in 0.18.0, not re-checked | [pricing](https://docs.novita.ai/guides/sandbox-pricing) |
59
61
  | [DigitalOcean Harness Runtime](https://sandboxrouter.ai/providers/digitalocean) | up to $0.126 | none | not run yet | [pricing](https://docs.digitalocean.com/products/managed-agents/agent-harness-runtime/details/pricing/) |
60
- | [Freestyle](https://sandboxrouter.ai/providers/freestyle) | $0.134 | none | passed (2026-11-13) | [pricing](https://www.freestyle.sh/docs/vms/pricing-and-limits) |
61
- | [Beam](https://sandboxrouter.ai/providers/beam) | $0.140 | $20/mo (credited) | passed (2026-11-18) | [pricing](https://www.beam.cloud/pricing) |
62
+ | [Freestyle](https://sandboxrouter.ai/providers/freestyle) | $0.134 | none | passed, last checked 2026-11-13 | [pricing](https://www.freestyle.sh/docs/vms/pricing-and-limits) |
63
+ | [Beam](https://sandboxrouter.ai/providers/beam) | $0.140 | $20/mo (credited) | passed, last checked 2026-11-18 | [pricing](https://www.beam.cloud/pricing) |
62
64
  | [CodeSandbox SDK (Together)](https://sandboxrouter.ai/providers/codesandbox) | $0.149 | none | not run yet | [pricing](https://docs.together.ai/docs/together-code-sandbox-legacy) |
63
- | [Fly.io Sprites](https://sandboxrouter.ai/providers/sprites) | up to $0.164 | none | passed (2026-11-13) | [pricing](https://fly.io/sprites) |
64
- | [Blaxel](https://sandboxrouter.ai/providers/blaxel) | $0.166 | none | passed (2026-11-13) | [pricing](https://blaxel.ai/pricing) |
65
+ | [Fly.io Sprites](https://sandboxrouter.ai/providers/sprites) | up to $0.164 | none | passed, last checked 2026-11-13 | [pricing](https://fly.io/sprites) |
66
+ | [Blaxel](https://sandboxrouter.ai/providers/blaxel) | $0.166 | none | passed, last checked 2026-11-13 | [pricing](https://blaxel.ai/pricing) |
67
+ | [Daytona](https://sandboxrouter.ai/providers/daytona) | $0.166 (from your own image; the default image is 1 vCPU / 1 GB) | none | passed, last checked 2026-11-13; changed in 0.18.0, not re-checked | [pricing](https://www.daytona.io/pricing) |
68
+ | [E2B](https://sandboxrouter.ai/providers/e2b) | $0.166 (from your own image; the default image is 2 vCPU / 0.5 GB) | none | passed, last checked 2026-11-13 | [pricing](https://e2b.dev/pricing) |
65
69
  | [HOPX](https://sandboxrouter.ai/providers/hopx) | $0.166 | none | not run yet | [pricing](https://hopx.ai/pricing) |
66
- | [Superserve](https://sandboxrouter.ai/providers/superserve) | $0.166 | maybe $20/mo (credited) | passed (2026-11-13) | [pricing](https://superserve.ai/pricing) |
67
- | [Tensorlake](https://sandboxrouter.ai/providers/tensorlake) | up to $0.200 | none | passed (2026-11-14) | [pricing](https://www.tensorlake.ai/pricing) |
70
+ | [Superserve](https://sandboxrouter.ai/providers/superserve) | $0.166 | maybe $20/mo (credited) | passed, last checked 2026-11-13 | [pricing](https://superserve.ai/pricing) |
71
+ | [Tensorlake](https://sandboxrouter.ai/providers/tensorlake) | up to $0.200 | none | passed, last checked 2026-11-14 | [pricing](https://www.tensorlake.ai/pricing) |
68
72
  | [Upstash Box](https://sandboxrouter.ai/providers/upstash) | up to $0.200 | none | not run yet | [pricing](https://upstash.com/pricing/box) |
69
- | [Cloudflare Sandbox](https://sandboxrouter.ai/providers/cloudflare) | up to $0.216 | $5/mo | passed (2026-11-13) | [pricing](https://developers.cloudflare.com/containers/platform/pricing/) |
70
- | [Amazon Bedrock AgentCore Code Interpreter](https://sandboxrouter.ai/providers/agentcore) | up to $0.217 | none | passed (2026-11-13) | [pricing](https://aws.amazon.com/bedrock/agentcore/pricing/) |
71
- | [Modal](https://sandboxrouter.ai/providers/modal) | $0.238 | none | passed (2026-11-13) | [pricing](https://modal.com/pricing) |
72
- | [AWS Lambda MicroVMs](https://sandboxrouter.ai/providers/lambda) | $0.252 | none | passed (2026-11-13) | [pricing](https://aws.amazon.com/lambda/pricing/) |
73
+ | [Cloudflare Sandbox](https://sandboxrouter.ai/providers/cloudflare) | up to $0.216 (its 2 vCPU / 8 GB size) | $5/mo | passed, last checked 2026-11-13 | [pricing](https://developers.cloudflare.com/containers/platform/pricing/) |
74
+ | [Amazon Bedrock AgentCore Code Interpreter](https://sandboxrouter.ai/providers/agentcore) | up to $0.217 | none | passed, last checked 2026-11-13 | [pricing](https://aws.amazon.com/bedrock/agentcore/pricing/) |
75
+ | [Modal](https://sandboxrouter.ai/providers/modal) | $0.238 | none | passed, last checked 2026-11-13 | [pricing](https://modal.com/pricing) |
76
+ | [AWS Lambda MicroVMs](https://sandboxrouter.ai/providers/lambda) | $0.252 | none | passed, last checked 2026-11-13 | [pricing](https://aws.amazon.com/lambda/pricing/) |
73
77
  | [Deno Sandbox](https://sandboxrouter.ai/providers/deno) | up to $0.300 | $20/mo | not run yet | [pricing](https://deno.com/sandbox) |
74
78
  | [Runloop](https://sandboxrouter.ai/providers/runloop) | $0.317 | none | not run yet | [pricing](https://www.runloop.ai/pricing) |
75
- | [Vercel Sandbox](https://sandboxrouter.ai/providers/vercel) | up to $0.341 | none | passed (2026-11-13) | [pricing](https://vercel.com/docs/vercel-sandbox/pricing) |
79
+ | [Vercel Sandbox](https://sandboxrouter.ai/providers/vercel) | up to $0.341 | none | passed, last checked 2026-11-13; changed in 0.20.0, not re-checked | [pricing](https://vercel.com/docs/vercel-sandbox/pricing) |
76
80
  | [InstaBox (sign-up waitlisted)](https://sandboxrouter.ai/providers/instabox) | $0.017 | none | not run yet | [pricing](https://instabox.sh/docs/pricing.md) |
77
- | [Koyeb Sandboxes (not taking new accounts)](https://sandboxrouter.ai/providers/koyeb) | $0.058 | $29/mo | not run yet | [pricing](https://www.koyeb.com/docs/reference/instances) |
81
+ | [Koyeb Sandboxes (not taking new accounts)](https://sandboxrouter.ai/providers/koyeb) | $0.058 (its 4 vCPU / 4 GB size) | $29/mo | not run yet | [pricing](https://www.koyeb.com/docs/reference/instances) |
78
82
  | [Dedalus Machines (sign-up waitlisted)](https://sandboxrouter.ai/providers/dedalus) | $0.149 | none | not run yet | [pricing](https://docs.dedaluslabs.ai/dcs/dm/pricing) |
79
83
  | [LangSmith Sandboxes (sign-up waitlisted)](https://sandboxrouter.ai/providers/langsmith) | $0.189 | none | not run yet | [pricing](https://www.langchain.com/pricing) |
80
- | [OpenScale Sandboxes](https://sandboxrouter.ai/providers/openscale) | skipped (default image is 2 vCPU / 1 GB; a bigger size needs image.openscale) | none | passed (2026-11-13) | [pricing](https://openscale.so/sandboxes) |
81
- | [Azure Container Apps dynamic sessions](https://sandboxrouter.ai/providers/azure) | skipped (max 1 vCPU) | none | not run yet | [pricing](https://learn.microsoft.com/en-us/azure/container-apps/billing#dynamic-sessions) |
82
- | [Daytona](https://sandboxrouter.ai/providers/daytona) | skipped (default image is 1 vCPU / 1 GB; a bigger size needs image.daytona) | none | passed (2026-11-13) | [pricing](https://www.daytona.io/pricing) |
83
- | [Alibaba Cloud Agent Sandbox](https://sandboxrouter.ai/providers/alibaba) | skipped (max 2 GB memory) | none | not run yet | [pricing](https://www.alibabacloud.com/help/en/agent-sandbox/product-overview/billing-overview) |
84
- | [Novita AI Agent Sandbox](https://sandboxrouter.ai/providers/novita) | skipped (default image is 2 vCPU / 1 GB; a bigger size needs image.novita) | none | passed (2026-11-13) | [pricing](https://docs.novita.ai/guides/sandbox-pricing) |
85
- | [Google Cloud Agent Platform](https://sandboxrouter.ai/providers/google) | skipped (max 1 vCPU) | none | passed (2026-11-18) | [pricing](https://cloud.google.com/products/gemini-enterprise-agent-platform/pricing) |
86
- | [E2B](https://sandboxrouter.ai/providers/e2b) | skipped (default image is 2 vCPU / 0.5 GB; a bigger size needs image.e2b) | none | passed (2026-11-13) | [pricing](https://e2b.dev/pricing) |
87
- | [Docker (local)](https://sandboxrouter.ai/providers/docker) | free | none | passed (2026-11-13) | [pricing](https://docs.docker.com/engine/) |
84
+ | [Azure Container Apps dynamic sessions](https://sandboxrouter.ai/providers/azure) | not at this size (max 1 vCPU) | none | not run yet | [pricing](https://learn.microsoft.com/en-us/azure/container-apps/billing#dynamic-sessions) |
85
+ | [Alibaba Cloud Agent Sandbox](https://sandboxrouter.ai/providers/alibaba) | not at this size (max 2 GB memory) | none | not run yet | [pricing](https://www.alibabacloud.com/help/en/agent-sandbox/product-overview/billing-overview) |
86
+ | [Google Cloud Agent Platform](https://sandboxrouter.ai/providers/google) | not at this size (max 1 vCPU) | none | passed, last checked 2026-11-18 | [pricing](https://cloud.google.com/products/gemini-enterprise-agent-platform/pricing) |
87
+ | [Docker (local)](https://sandboxrouter.ai/providers/docker) | free | none | passed, last checked 2026-11-13 | [pricing](https://docs.docker.com/engine/) |
88
88
 
89
89
  Checked 2026-11-04 to 2026-11-27.
90
90
 
package/dist/catalog.d.ts CHANGED
@@ -370,6 +370,40 @@ export declare function fittingSpec(id: ProviderId): {
370
370
  vcpu: number;
371
371
  memoryGb: number;
372
372
  };
373
+ /**
374
+ * The size a provider rents, and `hourlyCost` prices, when it only sells fixed sizes and the smallest one that
375
+ * fits is not the size asked for: Cloudflare's 2 vCPU / 8 GB instance for a 2 vCPU / 4 GB request. Null when
376
+ * the price is for the size asked for, when the default image fixes the size (see `fixedSize`), and for
377
+ * providers whose rounding is not a published size. A price shown under the requested size must say so
378
+ * when this is not null.
379
+ */
380
+ export declare function billedSize(id: ProviderId, spec?: SandboxSpec): {
381
+ vcpu: number;
382
+ memoryGb: number;
383
+ } | null;
384
+ /**
385
+ * One cell of a price table: what this provider's list price is at this size, and what a reader must be told
386
+ * about it. The README table and the website's tables are both built from this, so they cannot disagree.
387
+ *
388
+ * - `unfit`: the provider cannot run this size at all (and `usd` is then not a price to show).
389
+ * - `ownImage`: its default image is smaller, but it runs this size from your own image or template; `usd` is
390
+ * the price at this size, which needs that image. The router skips it at this size until you name one.
391
+ * - `billedAs`: it only sells fixed sizes and `usd` is for the smallest that fits (see `billedSize`).
392
+ */
393
+ export declare function tablePrice(id: ProviderId, size: {
394
+ vcpu: number;
395
+ memoryGb: number;
396
+ }): {
397
+ usd: number;
398
+ unfit: string | null;
399
+ ownImage?: true;
400
+ billedAs?: {
401
+ vcpu: number;
402
+ memoryGb: number;
403
+ };
404
+ };
405
+ /** A provider's name as running text uses it: no parenthetical, and no trailing "Sandbox" when one word is left. */
406
+ export declare function shortName(id: ProviderId): string;
373
407
  /**
374
408
  * Estimated USD per hour for this spec on this provider (list price, while running). For providers that
375
409
  * bill CPU only while it's busy ("active-cpu"), the CPU part is scaled by `spec.cpuUtilization` (default
package/dist/catalog.js CHANGED
@@ -115,7 +115,7 @@ const ENTRIES = [
115
115
  pricing: {
116
116
  vcpuHour: 0.0504,
117
117
  gbHour: 0.0162,
118
- note: "per second; free Hobby tier ($100 one-time credit, 1-hour sessions, 20 at once); Pro $150/mo for longer sessions",
118
+ note: "per second; free Hobby tier ($100 one-time credit, 1-hour sessions, 10 at once); Pro $150/mo for longer sessions",
119
119
  source: "https://e2b.dev/pricing",
120
120
  checked: "2026-11-04",
121
121
  },
@@ -883,6 +883,58 @@ function fullHourlyCost(id, spec = {}) {
883
883
  return Math.max(vcpu, Math.ceil(mem / 4)) * pricing.vcpuHour;
884
884
  return vcpu * pricing.vcpuHour + mem * pricing.gbHour;
885
885
  }
886
+ /**
887
+ * The size a provider rents, and `hourlyCost` prices, when it only sells fixed sizes and the smallest one that
888
+ * fits is not the size asked for: Cloudflare's 2 vCPU / 8 GB instance for a 2 vCPU / 4 GB request. Null when
889
+ * the price is for the size asked for, when the default image fixes the size (see `fixedSize`), and for
890
+ * providers whose rounding is not a published size. A price shown under the requested size must say so
891
+ * when this is not null.
892
+ */
893
+ export function billedSize(id, spec = {}) {
894
+ if (fixedSize(id, spec))
895
+ return null;
896
+ const vcpu = spec.vcpu ?? DEFAULT_VCPU;
897
+ const mem = spec.memoryGb ?? DEFAULT_MEMORY_GB;
898
+ const lambda = [0.5, 1, 2, 4, 8].find((s) => s >= Math.max(mem, vcpu * 2)) ?? 8;
899
+ const sold = id === "vercel" ? vercelSandboxSize(spec)
900
+ : id === "digitalocean" ? digitalOceanSize(vcpu, mem)
901
+ : id === "boat" ? BOAT_SIZES.find((b) => b.vcpu >= vcpu && b.memoryGb >= mem)
902
+ : id === "cloudflare" ? cloudflareInstance(vcpu, mem)
903
+ : id === "lambda" ? { vcpu: lambda / 2, memoryGb: lambda }
904
+ : id === "superserve" ? { vcpu: 2, memoryGb: 4 }
905
+ : id === "instabox" ? instaboxSize(vcpu, mem)
906
+ : id === "agent37" ? agent37Shape(vcpu, mem)
907
+ : id === "codesandbox" ? codesandboxTier(vcpu, mem)
908
+ : id === "koyeb" ? koyebInstance(vcpu, mem)
909
+ : id === "freestyle" ? freestyleSize(vcpu, mem)
910
+ : id === "upstash" ? upstashSize(vcpu, mem)
911
+ : id === "langsmith" ? langsmithSize(vcpu, mem)
912
+ : undefined;
913
+ return sold && (sold.vcpu !== vcpu || sold.memoryGb !== mem) ? { vcpu: sold.vcpu, memoryGb: sold.memoryGb } : null;
914
+ }
915
+ /**
916
+ * One cell of a price table: what this provider's list price is at this size, and what a reader must be told
917
+ * about it. The README table and the website's tables are both built from this, so they cannot disagree.
918
+ *
919
+ * - `unfit`: the provider cannot run this size at all (and `usd` is then not a price to show).
920
+ * - `ownImage`: its default image is smaller, but it runs this size from your own image or template; `usd` is
921
+ * the price at this size, which needs that image. The router skips it at this size until you name one.
922
+ * - `billedAs`: it only sells fixed sizes and `usd` is for the smallest that fits (see `billedSize`).
923
+ */
924
+ export function tablePrice(id, size) {
925
+ const reason = unfit(id, size);
926
+ if (reason?.startsWith("default image") && info(id).capabilities.includes("custom-image") && !unfit(id, withOwnImages(size))) {
927
+ return { usd: hourlyCost(id, withOwnImages(size)), unfit: null, ownImage: true };
928
+ }
929
+ const sold = reason ? null : billedSize(id, size);
930
+ return { usd: hourlyCost(id, size), unfit: reason, ...(sold ? { billedAs: sold } : {}) };
931
+ }
932
+ /** A provider's name as running text uses it: no parenthetical, and no trailing "Sandbox" when one word is left. */
933
+ export function shortName(id) {
934
+ const name = info(id).name.replace(/ \(.*\)$/, "");
935
+ const bare = name.replace(/ (AI Agent )?Sandbox(es)?$/, "");
936
+ return bare.includes(" ") ? name : bare;
937
+ }
886
938
  /**
887
939
  * Estimated USD per hour for this spec on this provider (list price, while running). For providers that
888
940
  * bill CPU only while it's busy ("active-cpu"), the CPU part is scaled by `spec.cpuUtilization` (default
@@ -0,0 +1,15 @@
1
+ import type { RoutedSandbox } from "./router.js";
2
+ /**
3
+ * Join this process's terminal to one in the sandbox: keys go in as they are typed (raw mode), output
4
+ * comes back as it is, and a window resize is passed on. Resolves with the exit code once the
5
+ * terminal's command ends, or with `detached` after Ctrl-] (the terminal stays open). The local
6
+ * terminal is put back as it was either way.
7
+ */
8
+ export declare function terminalSession(sbx: RoutedSandbox, opts?: {
9
+ cmd?: string;
10
+ attach?: string;
11
+ }): Promise<{
12
+ exitCode: number;
13
+ detached: boolean;
14
+ terminalId: string;
15
+ }>;
@@ -0,0 +1,52 @@
1
+ /** Ctrl-]: let go of the terminal and leave it open in the sandbox. */
2
+ const DETACH_KEY = 0x1d;
3
+ /**
4
+ * Join this process's terminal to one in the sandbox: keys go in as they are typed (raw mode), output
5
+ * comes back as it is, and a window resize is passed on. Resolves with the exit code once the
6
+ * terminal's command ends, or with `detached` after Ctrl-] (the terminal stays open). The local
7
+ * terminal is put back as it was either way.
8
+ */
9
+ export async function terminalSession(sbx, opts = {}) {
10
+ const input = process.stdin;
11
+ const output = process.stdout;
12
+ const size = () => ({ cols: output.columns || 80, rows: output.rows || 24 });
13
+ const onData = (bytes) => void output.write(bytes);
14
+ const term = opts.attach ? await sbx.attachTerminal(opts.attach, { onData }) : await sbx.terminal({ cmd: opts.cmd, ...size(), onData });
15
+ if (opts.attach)
16
+ await term.resize(size().cols, size().rows).catch(() => { });
17
+ const raw = input.isTTY === true;
18
+ let detached = false;
19
+ const onResize = () => void term.resize(size().cols, size().rows).catch(() => { });
20
+ const onKeys = (data) => {
21
+ if (raw && data.length === 1 && data[0] === DETACH_KEY) {
22
+ detached = true;
23
+ return term.detach();
24
+ }
25
+ term.write(data).catch(() => { });
26
+ };
27
+ // Piped input that ends is the same as Ctrl-D at a keyboard.
28
+ const onEnd = () => void term.write("\x04").catch(() => { });
29
+ if (raw)
30
+ input.setRawMode(true);
31
+ input.on("data", onKeys);
32
+ if (!raw)
33
+ input.once("end", onEnd);
34
+ input.resume();
35
+ output.on("resize", onResize);
36
+ try {
37
+ return { exitCode: (await term.wait()).exitCode, detached: false, terminalId: term.id };
38
+ }
39
+ catch (error) {
40
+ if (!detached)
41
+ throw error;
42
+ return { exitCode: 0, detached: true, terminalId: term.id };
43
+ }
44
+ finally {
45
+ if (raw)
46
+ input.setRawMode(false);
47
+ input.off("data", onKeys);
48
+ input.off("end", onEnd);
49
+ input.pause();
50
+ output.off("resize", onResize);
51
+ }
52
+ }
package/dist/cli.js CHANGED
@@ -67,6 +67,10 @@ Usage:
67
67
  sandboxrouter desktop [--os linux|windows|android|ios] [--user ID] [--control]
68
68
  get or create a computer and print a link to watch (or take over) its screen
69
69
  sandboxrouter screenshot <provider:id> [--out screen.png]
70
+ sandboxrouter terminal [<provider:id>] [--cmd "htop"] [--attach TERMINAL] [spec flags] [route flags] [--keep]
71
+ a live terminal in a sandbox: keys, colours, Ctrl-C, full-screen programs, resize.
72
+ With an id it opens in that sandbox; without, in a new one that is killed at the end
73
+ (--keep leaves it). Ctrl-] lets go and leaves the terminal open; --attach comes back to it
70
74
  sandboxrouter serve [--port 8787] [--host 127.0.0.1] [--cors https://site.example,http://localhost:3000]
71
75
 
72
76
  Spec flags: --vcpu N --memory GB --gpu T4 --timeout MIN --expect SEC (how long you'll use it; ranks by the real bill)
@@ -132,6 +136,8 @@ const { values, positionals } = parseArgs({
132
136
  minutes: { type: "string" },
133
137
  "no-load": { type: "boolean" },
134
138
  by: { type: "string" },
139
+ cmd: { type: "string" },
140
+ attach: { type: "string" },
135
141
  },
136
142
  });
137
143
  const list = (s) => (s ? s.split(",").map((x) => x.trim()).filter(Boolean) : undefined);
@@ -253,10 +259,13 @@ async function main() {
253
259
  const secs = (s) => (s >= 10 ? `${s.toFixed(0)} s` : `${s.toFixed(1)} s`);
254
260
  const money = (n) => (n === undefined ? "n/a" : n >= 1 ? `$${n.toFixed(2)}` : n >= 0.01 ? `$${n.toFixed(3)}` : `$${n.toPrecision(2)}`);
255
261
  console.log(r.basis);
256
- console.log(`Data through ${r.dataThrough.slice(0, 10)}; sandboxrouter.ai/methodology explains how it's measured.\n`);
262
+ // Rows were measured on different days: say the span, not only the newest date.
263
+ const days = [...new Set(r.results.map((x) => x.measuredAt.slice(0, 10)))].sort();
264
+ const when = !days.length ? `through ${r.dataThrough.slice(0, 10)}` : days.length === 1 ? `on ${days[0]}` : `between ${days[0]} and ${days.at(-1)}`;
265
+ console.log(`Measured ${when} from one test machine, a few runs per provider; sandboxrouter.ai/methodology explains how.\n`);
257
266
  for (const x of r.results.slice(0, 10)) {
258
267
  const cost = job === "start" ? `${money(x.hourlyUsd)}/h` : count > 1 ? `${money(x.usdTotal)} for ${count}` : money(x.usdEach);
259
- 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(" · ")}` : ""}`);
268
+ console.log(`${x.otherSize ? " –" : 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(" · ")}` : ""}`);
260
269
  }
261
270
  return;
262
271
  }
@@ -660,6 +669,28 @@ async function main() {
660
669
  console.log(`wrote ${out} (${img.byteLength} bytes)`);
661
670
  return;
662
671
  }
672
+ if (cmd === "terminal") {
673
+ const { terminalSession } = await import("./cli-terminal.js");
674
+ const id = rest[0];
675
+ const sbx = id ? await router.get(id) : await router.create(spec, route);
676
+ // A sandbox this command started is not left billing, unless asked.
677
+ const mine = !id && !values.keep;
678
+ if (!id)
679
+ console.error(`> ${sbx.id} on ${sbx.provider}${mine ? " (killed when you leave the terminal; --keep leaves it running)" : ""}`);
680
+ try {
681
+ const r = await terminalSession(sbx, { cmd: values.cmd, attach: values.attach });
682
+ process.exitCode = r.exitCode;
683
+ if (r.detached && !mine)
684
+ console.error(`\n> the terminal is still open. To come back: sandboxrouter terminal ${sbx.id} --attach ${r.terminalId}`);
685
+ }
686
+ finally {
687
+ if (mine)
688
+ await sbx.kill();
689
+ else if (!id)
690
+ console.error(`> kept alive: ${sbx.id}`);
691
+ }
692
+ return;
693
+ }
663
694
  if (cmd === "serve") {
664
695
  const port = num(values.port) ?? Number(process.env.PORT ?? 8787);
665
696
  const host = values.host ?? "127.0.0.1";
@@ -37,13 +37,31 @@ export interface ConformanceRow {
37
37
  };
38
38
  }
39
39
  /**
40
- * One-word status of a provider's last real-account run, for tables: "passed" (every step that applies),
41
- * "failing" (the last run had failures), or "untested" (only mock-tested; no real run saved yet).
40
+ * The releases after a check that changed the provider it checked: versions released after the day of the
41
+ * check whose changelog has an entry under "Changed" or "Fixed" titled "<Provider>: ...". A check says what
42
+ * was true of the adapter on the day it ran, so a later change means the result is older than the code.
43
+ * Read from the changelog, not from git, so every build gets the same answer.
42
44
  */
43
- export declare function liveStatus(row: ConformanceRow): {
45
+ export declare function changedSinceCheck(changelog: string, provider: {
46
+ id: string;
47
+ name: string;
48
+ }, checkedOn: string): string[];
49
+ export interface LiveStatus {
44
50
  status: "passed" | "failing" | "untested";
51
+ /** The result with the day it was last checked, e.g. "passed, last checked 2026-11-13". */
45
52
  label: string;
46
- };
53
+ /** The day (YYYY-MM-DD) of the last saved check, when there is one. */
54
+ checked?: string;
55
+ /** Releases after that check that changed this provider (`changedSinceCheck`); the check has not been re-run on them. */
56
+ changedSince?: string[];
57
+ }
58
+ /**
59
+ * Status of a provider's last real-account run, for tables: "passed" (every step that applies), "failing"
60
+ * (the last run had failures), or "untested" (only mock-tested; no real run saved yet). The label always
61
+ * carries the day of that run as "last checked", because a pass is a statement about that day. Give the
62
+ * changelog to also learn whether the provider's adapter changed after it.
63
+ */
64
+ export declare function liveStatus(row: ConformanceRow, changelog?: string): LiveStatus;
47
65
  /** Saved check runs in `dir` (default results/conformance), keyed by provider. */
48
66
  export declare function loadConformance(dir?: string): Map<ProviderId, SavedCheck>;
49
67
  /** One row per sandbox provider in the catalog, scored against the current list of check steps. */
@@ -3,17 +3,59 @@ import { join } from "node:path";
3
3
  import { CATALOG } from "./catalog.js";
4
4
  import { CHECK_STEPS } from "./check.js";
5
5
  /**
6
- * One-word status of a provider's last real-account run, for tables: "passed" (every step that applies),
7
- * "failing" (the last run had failures), or "untested" (only mock-tested; no real run saved yet).
6
+ * The releases after a check that changed the provider it checked: versions released after the day of the
7
+ * check whose changelog has an entry under "Changed" or "Fixed" titled "<Provider>: ...". A check says what
8
+ * was true of the adapter on the day it ran, so a later change means the result is older than the code.
9
+ * Read from the changelog, not from git, so every build gets the same answer.
8
10
  */
9
- export function liveStatus(row) {
11
+ export function changedSinceCheck(changelog, provider, checkedOn) {
12
+ const day = checkedOn.slice(0, 10);
13
+ const short = provider.name.replace(/ \(.*\)$/, "");
14
+ const names = [provider.id, short, short.replace(/ (AI Agent )?Sandbox(es)?$/, "")].map((n) => n.toLowerCase());
15
+ const out = [];
16
+ let version = "";
17
+ let released = "";
18
+ let section = "";
19
+ for (const line of changelog.split("\n")) {
20
+ const v = line.match(/^## (\d+\.\d+\.\d+) \((\d{4}-\d{2}-\d{2})\)/);
21
+ if (v) {
22
+ [, version, released] = v;
23
+ section = "";
24
+ continue;
25
+ }
26
+ const h = line.match(/^### (.+)/);
27
+ if (h) {
28
+ section = h[1].trim();
29
+ continue;
30
+ }
31
+ const title = line.match(/^- \*\*([^:*]+):/)?.[1].trim().toLowerCase();
32
+ if (!title || !version || released <= day || !["Changed", "Fixed"].includes(section))
33
+ continue;
34
+ if (names.includes(title) && !out.includes(version))
35
+ out.push(version);
36
+ }
37
+ return out.reverse();
38
+ }
39
+ /**
40
+ * Status of a provider's last real-account run, for tables: "passed" (every step that applies), "failing"
41
+ * (the last run had failures), or "untested" (only mock-tested; no real run saved yet). The label always
42
+ * carries the day of that run as "last checked", because a pass is a statement about that day. Give the
43
+ * changelog to also learn whether the provider's adapter changed after it.
44
+ */
45
+ export function liveStatus(row, changelog) {
10
46
  const r = row.run;
11
47
  if (!r)
12
48
  return { status: "untested", label: "not run yet" };
13
49
  const day = r.date.slice(0, 10);
14
- if (r.failed.length)
15
- return { status: "failing", label: `failed ${r.failed.length} step${r.failed.length > 1 ? "s" : ""} (${day})` };
16
- return { status: "passed", label: `passed (${day})` };
50
+ const changed = changelog ? changedSinceCheck(changelog, { id: row.provider, name: row.name }, day) : [];
51
+ const stale = changed.length ? `; changed in ${changed.join(", ")}, not re-checked` : "";
52
+ const result = r.failed.length ? `failed ${r.failed.length} step${r.failed.length > 1 ? "s" : ""}` : "passed";
53
+ return {
54
+ status: r.failed.length ? "failing" : "passed",
55
+ label: `${result}, last checked ${day}${stale}`,
56
+ checked: day,
57
+ ...(changed.length ? { changedSince: changed } : {}),
58
+ };
17
59
  }
18
60
  /** Saved check runs in `dir` (default results/conformance), keyed by provider. */
19
61
  export function loadConformance(dir = "results/conformance") {
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The preview gate: a small reverse proxy that runs inside the sandbox, in front of one port of the
3
+ * app, and lets a request through only when it carries the link's token. Two versions that behave
4
+ * the same, one for `node` and one for `python3`, standard library only, so it runs on whatever
5
+ * the image has. `preview.ts` starts it and says what it is for; the rules it keeps are below.
6
+ *
7
+ * gate <listen ports, comma separated, 0 = any free> <app port> <seconds to live> <sha256 of the token, hex, or "-"> <its folder>
8
+ *
9
+ * - It only ever connects to 127.0.0.1:<app port>.
10
+ * - A request is let through when the gate's cookie holds the token, or (not for a page a browser
11
+ * opens: see next) when `?sr_token=` does. The token is compared as a SHA-256 in constant time;
12
+ * the gate is given only that hash, never the token.
13
+ * - A GET or HEAD that brings a valid `?sr_token=` and no cookie is answered with a redirect to the
14
+ * same path without the token, and the cookie (HttpOnly, Secure, SameSite=Lax, Path=/). The
15
+ * redirect is always to a path on the same host.
16
+ * - The token parameter and the gate's cookie are taken off before the request goes to the app.
17
+ * - One request per connection: the gate reads one request head (32 KB at most), forwards exactly
18
+ * its body (`Content-Length`; a chunked request body is refused with 411) and marks both sides
19
+ * `Connection: close`. An upgraded connection (WebSocket) is one client's and is piped until it ends.
20
+ * - Responses are passed on as they arrive, never held back or stored.
21
+ * - After the expiry every open connection is cut and every request gets 410. The gate leaves when
22
+ * its folder is removed (`revoke()`), and ten minutes after the expiry.
23
+ * - Nothing about a request is written anywhere.
24
+ *
25
+ * Neither script may contain a backtick or a dollar-brace: they are raw template strings.
26
+ */
27
+ export declare const GATE_NODE: string;
28
+ export declare const GATE_PYTHON: string;