Architecture
CloudRuntime Class
Implemented inesprit/runtime/cloud_runtime.py, the CloudRuntime manages cloud sandbox lifecycle:
Initialization
- Requires valid access token from
esprit login - Token stored in
~/.esprit/credentials.json - Throws
SandboxInitializationErrorif not authenticated
Configuration
Environment variables:| Variable | Default | Description |
|---|---|---|
ESPRIT_API_BASE | https://api.esprit.cloud | Cloud API endpoint |
ESPRIT_SCAN_MODE | quick | Scan mode: quick, deep, or compliance |
ESPRIT_CLOUD_SANDBOX_STATE_FILE | ~/.esprit/state/cloud_sandboxes.json | Tracked sandboxes for cleanup |
Sandbox Lifecycle
1. Sandbox Creation
Method:create_sandbox() (lines 381-463)
Creation Process
Creation Process
- Sanitize local sources (if scanning local code)
- Attempt legacy endpoint first:
- Fallback to modern endpoint on 404/405:
- Poll for tool server URL (max 240 seconds)
- Track sandbox in state file for cleanup
- Return SandboxInfo with credentials
2. Tool Server URL Polling
Method:_poll_tool_server_url() (lines 309-361)
Modern cloud sandboxes provision asynchronously:
- Max timeout: 240 seconds
- Poll interval: 1.5 seconds
- Connect timeout: 5 seconds
- Request timeout: 8 seconds
- First 30 seconds: Ignore transient “stopped” status (ECS warmup)
- After 30 seconds: Treat terminal states as failures
3. Retry Logic
Method:create_sandbox() with retry wrapper (lines 388-426)
- Tool server not ready within 240 seconds
- Automatically destroys unready sandbox before retry
4. Local Source Upload
Method:_sanitize_local_sources() (lines 227-247)
For local code scanning:
- CLI sends local source paths to cloud API
- Cloud API clones/uploads to sandbox
- Files available at
/workspace/<workspace_subdir>
5. Sandbox Info Response
Method:create_sandbox() returns SandboxInfo:
6. Sandbox Cleanup
Method:destroy_sandbox() (lines 493-506)
- Normal scan completion
- CLI process exit
- Manual cleanup via
esprit cleanup
State Tracking
Cloud sandboxes are tracked in~/.esprit/state/cloud_sandboxes.json:
Stale Sandbox Cleanup
Method:cleanup_stale_sandboxes() (lines 134-174)
Cleans up sandboxes from abrupt terminations:
- Before starting new scans
- After unexpected CLI crashes
- Manual cleanup via
esprit cleanup
Target Inference
Method:_infer_scan_target() (lines 177-224)
Cloud runtime automatically infers target from scan config:
Target Type Detection
Target Type Detection
Repository:Local Code:Web Application:IP Address:
Workspace Diffs
Method:get_workspace_diffs() (lines 471-491)
Retrieves file edits from cloud sandbox:
Error Handling
Authentication Errors
Authentication Errors
- No access token provided
- Invalid/expired token
- HTTP 401 response
API Errors
API Errors
- HTTP status code
- Response body (first 500 chars)
- Endpoint that failed
Connection Errors
Connection Errors
- Network connectivity issues
- DNS resolution failures
- Timeout connecting to API
Provisioning Timeout
Provisioning Timeout
- Sandbox not ready within 240 seconds
- After 2 retry attempts
- Automatically destroys unready sandbox
Advanced Cleanup
Method:cleanup() (lines 512-539)
Handles cleanup in different async contexts:
No Running Loop
No Running Loop
Active Loop
Active Loop
Fallback
Fallback
Performance & Scalability
Advantages over Docker
| Feature | Docker Runtime | Cloud Runtime |
|---|---|---|
| Setup | Requires Docker Desktop | No local dependencies |
| Resource Usage | Uses local CPU/RAM | Cloud resources |
| Scaling | Limited by host | Unlimited cloud capacity |
| Collaboration | Single machine | Team access |
| Persistence | Local only | Cloud storage |
| Network Speed | localhost | Internet latency |
Cost Optimization
- Sandboxes auto-terminate after inactivity
- Shared infrastructure across team
- Pay-per-use pricing model
- Automatic resource scaling
Security
- Sandboxes isolated per scan
- Encrypted communication (HTTPS)
- Token-based authentication
- Automatic credential rotation
- Audit logs in cloud console
Troubleshooting
Authentication failed
Authentication failed
- Run
esprit loginto re-authenticate - Check token:
cat ~/.esprit/credentials.json - Verify API endpoint:
echo $ESPRIT_API_BASE - Test connectivity:
curl https://api.esprit.cloud/health
Sandbox provisioning timeout
Sandbox provisioning timeout
- Check cloud service status
- Retry with:
esprit scan <target>(automatic retry) - Increase timeout (not configurable, fixed at 240s)
- Contact support if persistent
Connection errors
Connection errors
- Check internet connectivity
- Verify firewall allows HTTPS to
*.esprit.cloud - Check proxy settings:
env | grep -i proxy - Disable VPN if blocking cloud access
Stale sandboxes
Stale sandboxes
- Run
esprit cleanupto remove orphaned sandboxes - Check state file:
cat ~/.esprit/state/cloud_sandboxes.json - Manually delete via cloud console if needed
API Compatibility
Cloud runtime supports two API versions:Legacy API (v1)
api_url and auth_token.
Modern API (v2)
status field, requires polling for tool_server_url.
Auto-detection: Runtime tries legacy first, falls back to modern on 404/405.
Next Steps
Docker Sandbox
Alternative local runtime
Tools
Available tools in cloud sandboxes