Run OpenCode in a sandbox
Two small TypeScript applications run OpenCode inside a disposable Daytona or E2B sandbox. They use the same public execution and file API with either provider; switching providers only changes setup.
| Workflow | What it does | Source |
|---|---|---|
hello |
Asks OpenCode “What is 2 + 2?” and prints captured stdout/stderr. | Hello application |
edit |
Uploads message.txt, asks OpenCode to replace NAME with Beachside, and reads back Hello, Beachside!. The local fixture stays unchanged. |
File-edit application |
Source: examples. The examples README covers model overrides, bounds and failure handling in more depth.
Set up and run
Section titled “Set up and run”Use Bun 1.4.4 on the host. These examples live in the repository, so run them from a checkout:
git clone https://github.com/beachside-compute/beachside.gitcd beachsidebun install --frozen-lockfilebun run build:packagescp examples/.env.example examples/.env.localEdit examples/.env.local with the selected provider’s credentials. The scripts load this ignored file explicitly.
| Provider | Configuration | Prerequisites |
|---|---|---|
| Daytona | DAYTONA_API_KEY, DAYTONA_TARGET, DAYTONA_SNAPSHOT |
An active Linux snapshot in the target region. The connection selects daytona-default; organization policy must permit GitHub release downloads and model access. |
| E2B | E2B_API_KEY; optional E2B_TEMPLATE_ID (default base) |
A ready Linux template; creation explicitly selects internet. |
The guest needs glibc-based Linux on x64 or arm64, curl, tar, sha256sum, /bin/sh, Python 3, and the adapter’s Daytona shell/file utilities or E2B file prerequisites. The helper downloads pinned standalone OpenCode 1.18.35 from GitHub and verifies its pinned SHA-256 digest. It does not need npm in the guest.
Run either workflow with either provider:
bun run --cwd examples hello --provider daytonabun run --cwd examples edit --provider daytonabun run --cwd examples hello --provider e2bbun run --cwd examples edit --provider e2bEach invocation creates one sandbox and attempts destruction in finally, then closes the client. hello normally prints an answer containing 4; edit verifies the exact returned file bytes Hello, Beachside!\n.
Model and lifetime
Section titled “Model and lifetime”The explicit default is opencode/nemotron-3.5-lightning-free, an anonymous free model accepted in the recorded October 10, 2026 run. It needs no model API key. Availability can change; the README describes OPENCODE_MODEL and keyed-model overrides. Sandbox credentials stay on the host; only an explicitly named model key is forwarded to the guest. Sandbox compute can incur provider charges.
Sandbox lifetime is 600 seconds. Installation and agent deadlines are 120 and 180 seconds, with a 480-second overall workflow wait. Aborting a wait does not prove remote termination. Cleanup uses a separate 30-second destruction signal and 5-second client-close wait; failed cleanup reports the known sandbox ID. Uncertain operations retain a recovery reference and are not automatically replayed.
© 2026 Beachside Compute · Made by humans & in Texas