The micro-VM for AI agents — light enough to embed on your laptop, elastic enough to power an agentic cloud.
/*
* Copyright 2025 Daytona Platforms Inc.
* Modified by BoxLite AI, 2025-2026
* SPDX-License-Identifier: AGPL-3.0
*/
import { Column, CreateDateColumn, Entity, Index, PrimaryGeneratedColumn, Unique, UpdateDateColumn } from 'typeorm'
import { BoxClass } from '../enums/box-class.enum'
import { RunnerState } from '../enums/runner-state.enum'
import { RunnerUnschedulableReason } from '../enums/runner-unschedulable-reason.enum'
import { RunnerServiceInfo } from '../common/runner-service-info'
import { RunnerDataDiskRef } from '../common/runner-data-disk-ref'
@Entity()
@Unique(['region', 'name'])
@Index(['state', 'unschedulable', 'region'])
export class Runner {
@PrimaryGeneratedColumn('uuid')
id: string
@Column({
nullable: true,
})
domain: string | null
@Column({
nullable: true,
})
apiUrl: string | null
@Column({
nullable: true,
})
proxyUrl: string | null
@Column()
apiKey: string
@Column({
type: 'float',
default: 0,
})
cpu: number
@Column({
type: 'float',
default: 0,
})
memoryGiB: number
@Column({
type: 'float',
default: 0,
})
diskGiB: number
@Column({
nullable: true,
})
gpu: number | null
@Column({
nullable: true,
})
gpuType: string | null
@Column({
type: 'enum',
enum: BoxClass,
default: BoxClass.SMALL,
})
class: BoxClass
@Column({
type: 'float',
default: 0,
})
currentCpuLoadAverage: number
@Column({
type: 'float',
default: 0,
})
currentCpuUsagePercentage: number
@Column({
type: 'float',
default: 0,
})
currentMemoryUsagePercentage: number
@Column({
type: 'float',
default: 0,
})
currentDiskUsagePercentage: number
@Column({
type: 'float',
default: 0,
})
currentAllocatedCpu: number
@Column({
type: 'float',
default: 0,
})
currentAllocatedMemoryGiB: number
@Column({
type: 'float',
default: 0,
})
currentAllocatedDiskGiB: number
@Column({
default: 0,
})
currentStartedBoxes: number
@Column({
default: 0,
})
availabilityScore: number
@Column()
region: string
@Column()
name: string
@Column({
type: 'enum',
enum: RunnerState,
default: RunnerState.INITIALIZING,
})
state: RunnerState
@Column({
default: 'v0.0.0-dev',
nullable: true,
})
appVersion: string | null
@Column({
default: '0',
})
apiVersion: string
@Column({ default: false })
supportsPrivileged: boolean
@Column({ default: false })
nestedVirtualizationEnabled: boolean
/**
* Capabilities the runner binary declared in its latest healthcheck, e.g.
* `['filestore']`. This exists primarily for backward compatibility during
* rolling upgrades: null when the binary predates capability reporting, and
* dispatch then treats the runner as supporting nothing beyond the base
* protocol, so a pre-filestore v2 runner cannot be handed a filestore
* volume by mistake. Kept as a jsonb array rather than per-capability
* boolean columns so new capabilities can be added without a schema
* migration.
*/
@Column({
type: 'jsonb',
nullable: true,
default: null,
})
capabilities: string[] | null
@Column({
nullable: true,
type: 'timestamp with time zone',
})
lastChecked: Date
@Column({
default: false,
})
unschedulable: boolean
@Column({
type: 'enum',
enum: RunnerUnschedulableReason,
nullable: true,
})
unschedulableReason: RunnerUnschedulableReason | null
@Column({
default: false,
})
draining: boolean
@Column({
type: 'jsonb',
nullable: true,
default: null,
})
serviceHealth: RunnerServiceInfo[] | null
/**
* The cloud data disk behind this runner's `BOXLITE_HOME`, reported by the
* runner in each healthcheck. Refreshed whenever a heartbeat carries it and
* never written to null: an older runner binary reporting no disk must not
* erase the identity a newer one reported.
*/
@Column({
type: 'jsonb',
nullable: true,
default: null,
})
dataDiskRef: RunnerDataDiskRef | null
@CreateDateColumn({
type: 'timestamp with time zone',
})
createdAt: Date
@UpdateDateColumn({
type: 'timestamp with time zone',
})
updatedAt: Date
constructor(params: {
region: string
name: string
apiKey: string
apiVersion: string
cpu?: number
memoryGiB?: number
diskGiB?: number
domain?: string | null
apiUrl?: string
proxyUrl?: string
appVersion?: string | null
}) {
this.region = params.region
this.name = params.name
this.apiKey = params.apiKey
this.cpu = params.cpu ?? 0
this.memoryGiB = params.memoryGiB ?? 0
this.diskGiB = params.diskGiB ?? 0
this.domain = params.domain ?? null
this.apiUrl = params.apiUrl
this.proxyUrl = params.proxyUrl
this.class = BoxClass.SMALL
this.apiVersion = params.apiVersion
this.appVersion = params.appVersion ?? null
this.gpu = null
this.gpuType = null
if (this.apiVersion === '0') {
if (!this.apiUrl) {
throw new Error('API URL is required for runner version 0')
}
if (!this.proxyUrl) {
this.proxyUrl = this.apiUrl
}
}
}
}