Options
Port to listen on.
API key for Bearer token authentication. All requests except
GET /health must include an Authorization: Bearer <key> header. Falls back to the $ISOL8_API_KEY environment variable. The server exits with an error if neither is provided.Architecture
Persistent sessions are tracked in an in-memoryMap<string, SessionState>. When a request includes a sessionId, the server reuses the existing DockerIsol8 engine for that session. Ephemeral requests create a new engine per request and destroy it after execution.
Server Features
Global Concurrency Control
A server-wideSemaphore limits the number of concurrent container executions. The limit is set by config.maxConcurrent (default: 10). Every /execute and /execute/stream request must acquire a permit before running code.
Config Defaults
The server loads the isol8 config at startup and mergesconfig.defaults into every incoming request. This means server-side defaults for network, memoryLimit, cpuLimit, timeoutMs, sandboxSize, and tmpSize are applied automatically. Client-provided options in the request body override these defaults.
Session Management
Persistent sessions are stored in an in-memoryMap, keyed by sessionId. Each session holds a DockerIsol8 engine instance and a lastAccessedAt timestamp. Sessions are created on the first request with a given sessionId and reused on subsequent requests. Sessions can be explicitly destroyed via DELETE /session/:id.
Auto-Pruning
Whenconfig.cleanup.autoPrune is enabled (default: true), the server runs a cleanup interval every 60 seconds. Sessions that haven’t been accessed within config.cleanup.maxContainerAgeMs (default: 3,600,000ms / 1 hour) are stopped and removed.
Authentication
All endpoints exceptGET /health require a Bearer token matching the configured API key. The auth middleware returns 401 Unauthorized for missing or invalid tokens.
Endpoints
| Method | Path | Description |
|---|---|---|
GET | /health | Health check (no auth required) |
POST | /execute | Execute code, return result as JSON |
POST | /execute/stream | Execute code, stream output as SSE |
POST | /file | Upload a file to a persistent session |
GET | /file | Download a file from a persistent session |
DELETE | /session/:id | Destroy a persistent session |