Managoat.Sandbox.E2B.Api (managoat_sandbox v0.2.0)

Copy Markdown View Source

E2B control-plane client (api.e2b.app): sandbox lifecycle, listing, pause/resume, TTL and network policy.

E2B assigns sandbox ids — there are no user-chosen names — so Fountain's name-keyed identity is emulated through the metadata map: every sandbox is created with fountain_name set, and lookups filter on it server-side. A create/create race can therefore yield a duplicate, which the reaper's reconciliation converges (the same way it converges any leak).

Errors come back in the raw {:api_error, status, body} shape; Managoat.Sandbox.E2B normalizes them into the taxonomy.

Times are seconds. A running E2B sandbox always has a TTL — there is no unbounded state — so the adapter keeps live sandboxes alive with explicit set_timeout/2 heartbeats and creates with autoPause: true, making a missed heartbeat degrade to a pause (state preserved) rather than a kill.

Summary

Functions

Resume a paused sandbox (and extend its TTL) in one call.

Create a sandbox stamped with the fountain name. Returns the raw body.

Find the sandbox carrying fountain_name, across running AND paused — omitting the paused state would make every suspended sandbox look gone. Returns {:ok, info | nil}.

TTL granted at create and on every heartbeat.

Every fountain-stamped sandbox name on the account, running and paused, paginated via the X-Next-Token response header. Refuses a partial view.

Replace the sandbox's egress policy. allow: [] compiles to deny-all — E2B's denyOut 0.0.0.0/0 plus an allowlist is genuinely default-deny, so no fail-open translation is needed; the deny rule is always present.

Reset the sandbox's TTL to seconds from now (the turn heartbeat).

The template new sandboxes are created from (must carry the agent CLIs).

Functions

api_key!()

base_url()

connect(id)

Resume a paused sandbox (and extend its TTL) in one call.

create_sandbox(name)

Create a sandbox stamped with the fountain name. Returns the raw body.

delete_sandbox(id)

find_by_name(name)

Find the sandbox carrying fountain_name, across running AND paused — omitting the paused state would make every suspended sandbox look gone. Returns {:ok, info | nil}.

initial_ttl_s()

TTL granted at create and on every heartbeat.

list_all_names(max_pages \\ 40)

Every fountain-stamped sandbox name on the account, running and paused, paginated via the X-Next-Token response header. Refuses a partial view.

pause(id)

req()

set_network(id, allow_domains)

Replace the sandbox's egress policy. allow: [] compiles to deny-all — E2B's denyOut 0.0.0.0/0 plus an allowlist is genuinely default-deny, so no fail-open translation is needed; the deny rule is always present.

set_timeout(id, seconds \\ 1800)

Reset the sandbox's TTL to seconds from now (the turn heartbeat).

template()

The template new sandboxes are created from (must carry the agent CLIs).