Add `client` to `E2BSandbox` and `E2BSandboxBackend`
E2BSandbox can only get its key from E2B_API_KEY. That variable holds one key for the whole process, so an app whose users each have their own E2B account can't use them, and setting the variable per request can send one user's request with another's key. DaytonaSandbox, SpritesSandbox, BoxdSandbox and RenderSandbox all take a client for this.
E2B's SDK has a client too, e2b.E2B, available in every version we support (it arrived in 2.44.0 and our minimum is 2.48.0). It also carries the domain, proxy and other settings that otherwise only come from the environment. So this adds the same argument:
E2BSandboxBackend(client=...)andE2BSandbox(client=...), used to create, attach and destroy.- It is keyword-only and defaults to
None, which keeps reading the environment. Existing code behaves the same. - An agent spec can't set it. An explicit
from_speckeeps the spec's JSON schema exactly as it was, because thee2b.E2Bhint would otherwise reduce it to the bare name. I compared the schema before and after, and they are identical. - The error messages for a missing or rejected key now mention
client=, in the same words as Daytona's.
For different credentials per user, the docs show a small capability whose get_workspace builds the client from deps. E2B's client falls back to E2B_API_KEY when its key is empty or None, so the example checks for a key first.
Testing: unit tests use the fake SDK and check client reaches create, attach and destroy. I also ran the real e2b.E2B client against a local server to check the key each request carries: each client's key reached connect, kill and create, two clients at once stayed separate, and with no client all three used E2B_API_KEY. The live tier has not been run.
Checklist
- No breaking changes in accordance with the version policy.
- PR title is fit for the release changelog.
š¤ Generated with Claude Code