configure
Signature
E2B_* variables of this process so the stock e2b package, and the extras, talk to Anona. waitForCapacityMs and onCapacityWait set the default capacity wait of this package’s Sandbox in this process.
configure.ts
Sandbox
A subclass of e2b’s Sandbox. Every e2b method works unchanged and defaults to the Anona domain. Added:
Sandbox.create, Sandbox.connect and sandbox.connect() also take waitForCapacityMs and onCapacityWait.
Waiting for capacity
From@anona-labs/compute-sdk 0.3.0.
When every host is full, the API answers a create with 503 sandbox_capacity_unavailable, Should-Retry: true and Retry-After while it starts another host, which takes a few minutes. Sandbox.create and Sandbox.connect (which resumes a paused sandbox) then wait and try again instead of throwing: after each Retry-After, held between 1 and 30 seconds with a little jitter, until the wait runs out. Then the last error is thrown unchanged.
Each wait is also logged through the
logger option, at info. Your signal cancels a wait in progress, and each try keeps your requestTimeoutMs; e2b’s own retries still apply inside each try.
Only a 503 marked Should-Retry: true is retried: no capacity yet (sandbox_capacity_unavailable), the platform starting (sandbox_engine_starting) or settling (sandbox_engine_unavailable), or a size being prepared (sandbox_size_preparing). Everything else is thrown at once: a plan limit (403 or 429 plan_limit_exceeded), any 4xx, and a 503 with Should-Retry: false or without the header, which comes from something in front of the API and may mean the sandbox already started.
capacity_wait.ts
node:diagnostics_channel); elsewhere it is off. The stock e2b package’s Sandbox does not wait.
sandbox.live
ViewerToken has token, expiresAt (Date), embedUrl and claims(). toString() and toJSON() never include the token.
live_tokens.ts
InvalidArgumentError, 401/403 AuthenticationError, 404 NotFoundError, 429 RateLimitError, others SandboxError.
sandbox.ssh
SshCertificate is { cert, user, host, proxyCommand, expiresAt? }. See SSH.
sandbox.idlePause
Pauses the sandbox once nothing has used it for a while. Not the same as
lifecycle: { onTimeout: "pause" }, which acts when the deadline runs out;
idle pause has no deadline. See Lifecycle for what counts
as use.
idle_pause_sdk.ts
Sandbox.connect(sandboxId).
Desktop
There is no desktop subclass in TypeScript: create with@e2b/desktop, then Sandbox.connect(desk.sandboxId) from @anona-labs/compute-sdk for live.desktopUrl(). See Desktop.
Exports
Sandbox, configure, applyEnv, anonaDefaults, Live, ViewerToken, Ssh, IdlePause, MAX_IDLE_PAUSE_MINUTES, CHANNELS, SCOPES, MIN_TTL, MAX_TTL, DEFAULT_DOMAIN, DEFAULT_API_URL, DOMAIN_ENV, ENV_MAP, DEFAULT_WAIT_FOR_CAPACITY_MS, CAPACITY_WAIT_ENV, and the types ConfigureOpts, AnonaSandboxOpts, AnonaSandboxConnectOpts, CapacityWaitOpts, CapacityWaitInfo, OnCapacityWait, ViewerScope, ViewerChannel, ViewerTokenOpts, ViewerTokenClaims, SshCertificate, SshConfigOpts.