How to Run OpenCode in a Cloud Sandbox and Stream It to Ghostty
Brief
The setup keeps OpenCode running in an Upstash Box while a local Ghostty terminal connects through an HTTP-based relay.
How the relay works
- A host runs OpenCode in a pseudo-terminal and exchanges terminal data with a laptop client over two Upstash Realtime channels.
- Realtime keeps the last 512 messages per channel for replay after brief disconnects; sequence numbers restore message order.
Performance and reconnection
- Both ends use one HTTP/2 connection. The article reports that host emits fall to 1.4 ms when the Box and Redis database are both in us-east-1, plus about 10 ms added by the relay.
- Boxes auto-pause after 1 hour on the free plan or 6 hours on paid plans. The client can wake a paused Box; resuming takes about 9 seconds.
Requirements
- The project uses an Upstash Box with OpenCode, an Upstash Redis database in the same region, and @upstash/realtime 1.2 or newer.
- The source code is available at upstash/remote-sandbox-terminal on GitHub.
Generated by AI from the original article. Check the source for full details.