MonkeyBox

Cloud dev environments with full Linux containers. Create, snapshot, and template boxes for AI agents, dev workflows, or sandboxed code execution.

Create a Box

typescript
const box = await db.boxes.create({
  name: 'my-workspace',
  image: 'default',
  size: 'small',              // 'nano' | 'small' | 'medium' | 'large' | 'xlarge'
  env: { NODE_ENV: 'development' },
  idleTimeout: 3600,          // Auto-pause after 1 hour of inactivity
})

console.log(box.id) // "box_01JDXYZ..."

Execute Commands

typescript
const result = await box.exec('echo "Hello from the box"')
console.log(result.stdout)   // "Hello from the box"
console.log(result.exitCode) // 0

// With options
const build = await box.exec('npm run build', {
  cwd: '/workspace/my-project',
  timeout: 60000,
  env: { CI: 'true' },
})

Upload & Download Files

typescript
// Upload a file
await box.upload('/workspace/config.json', JSON.stringify({ key: 'value' }))

// Download a file
const content = await box.download('/workspace/output.txt')
console.log(new TextDecoder().decode(content))

Lifecycle Management

typescript
// Pause (preserves state, stops billing compute)
await box.pause()

// Resume
await box.resume()

// Get box info
const info = await box.info()
console.log(info.status) // 'running' | 'paused' | 'starting' | 'destroyed'

// Adjust idle timeout
await box.setIdleTimeout(7200)

// Destroy permanently
await box.destroy()
Note: Boxes auto-pause after the idle timeout expires. Pause reasons are tracked: manual, idle_timeout, or host_loss.

Snapshots

Capture the full state of a box and restore it later.

typescript
// Take a snapshot
const snapshot = await box.snapshot({ name: 'after-setup' })

// List all snapshots
const snapshots = await db.boxes.snapshots.list()

// Create a new box from a snapshot
const restored = await snapshot.createBox({ name: 'restored-workspace' })

// Delete a snapshot
await snapshot.delete()

Templates

Build reusable images from Dockerfiles. Every box created from a template starts with the same pre-configured environment.

typescript
// Build a template
const build = await db.boxes.templates.build({
  name: 'python-ml',
  description: 'Python with ML libraries',
  from: 'default',
  dockerfile: `FROM default
RUN pip install numpy pandas scikit-learn torch`,
})

// Check build status
const status = await db.boxes.templateBuilds.get(build.buildId)
console.log(status.status) // 'queued' | 'building' | 'ready' | 'failed'

// Create a box from the template
const mlBox = await db.boxes.create({
  name: 'training-run',
  image: build.templateId!,
  size: 'large',
})

Terminal Sessions

typescript
// Create a terminal session
const terminal = await box.createTerminal({
  clientType: 'agent',  // 'console' | 'cli' | 'agent'
  cwd: '/workspace',
  cols: 120,
  rows: 40,
})

// List active terminals
const terminals = await box.listTerminals()

// Close a terminal
await box.closeTerminal(terminal.terminalSessionId)

Mounts

typescript
// Add a mount
await box.addMount({ source: '/data/shared', target: '/mnt/shared', readonly: true })

// List mounts
const mounts = await box.listMounts()

// Remove a mount
await box.removeMount('/mnt/shared')

Networking

typescript
// Get the box's HTTP URL (for web servers running inside)
const url = await box.getUrl()
// → "https://box-01JDXYZ.monkeyhub.io"

List & Get Boxes

typescript
// List all running boxes
const running = await db.boxes.list({ status: 'running' })

// Get an existing box by ID
const existing = await db.boxes.get('box_01JDXYZ...')

Box Sizes

SizeUse Case
nanoScripts, linters, lightweight tasks
smallStandard development, small builds
mediumLarger builds, moderate workloads
largeHeavy compilation, ML training
xlargeGPU workloads, large-scale processing