Prerequisites
- Backend running (see Backend Setup)
- A Sprites account and API token (production only)
Environment variables
Add these toapps/backend/.env:
Development (local mode)
No additional setup is required. WithSPRITES_ENABLED=false, the backend uses LocalSandbox — commands run via child_process.exec on the backend host, isolated to the WORKING_DIR path.
This mode is only suitable for development. Multiple concurrent chats will share the same filesystem.
Production (Sprites)
1. Create a Sprites account
Sign up at sprites.fly.dev and obtain an API token from your account settings.2. Configure the backend
3. How sandboxes are provisioned
When a chat first needs a sandbox, the backend:- Calls the Sprites API to create (or reuse) a sprite named
zuko-{chatId}-{threadId} - Sets up the working directory and installs dependencies
- Marks the sandbox
activein the database - Starts the SSE lifecycle stream so the frontend reflects the current state
E2E / testing
For end-to-end tests, you can pin a specific sandbox instead of provisioning a new one:Verifying the setup
Start the backend and open a chat. TheSandboxStatusBadge in the top-right of the chat window shows the current state:
- Yellow / pulsing — sandbox is being provisioned
- Green — sandbox is active and ready
- Zinc — sandbox is hibernated (click Resume or send a message to wake it)
- Red — an error occurred (hover the badge for details)
Troubleshooting
Badge shows 'failed'
Badge shows 'failed'
Check the backend logs for a
SandboxLifecycleService error. Common causes:SPRITES_TOKENis missing or invalidSPRITES_API_BASE_URLis unreachable- The sandbox name already exists on Sprites with a conflicting state
POST /api/sandboxes/:id/resume or create a new chat to reprovision.Sandbox stays 'hibernated' and won't wake
Sandbox stays 'hibernated' and won't wake
Confirm
SPRITES_ENABLED=true and that SPRITES_TOKEN is valid. If the
Sprites API is unreachable, startSprite will fail silently and the sandbox
will remain hibernated. Check backend logs for startSprite returned an error.Local mode: commands fail with permission errors
Local mode: commands fail with permission errors
In local mode, commands run as the backend process user. Ensure the backend
has read/write access to
WORKING_DIR and that the directory exists.SSE badge never updates
SSE badge never updates
The frontend proxies SSE through
/api/proxy/sandboxes/:id/lifecycle/events. Confirm:- The backend is running and reachable from the Next.js server
BACKEND_URLinapps/web/.envpoints to the correct backend address- No reverse proxy is buffering the SSE stream (set
X-Accel-Buffering: noif using nginx)